//package com.verify.verifyalism2.controller;
//
//import cn.tass.SRJ1933.devices.constant.TACryptConst;
//import cn.tass.SRJ1933.devices.inf.TassSignServerApi;
//import cn.tass.SRJ1933.devices.params.custom.yl.pos.CUPSignDataExResponse;
//import cn.tass.SRJ1933.devices.params.custom.yl.pos.CUPVerifySignDataExResponse;
//import cn.tass.SRJ1933.devices.params.custom.yl.rl.*;
//import cn.tass.SRJ1933.devices.params.request.p7Sign.P7Attribute;
//import cn.tass.SRJ1933.devices.params.request.timestamp.TSPAccuracy;
//import cn.tass.SRJ1933.devices.params.request.timestamp.TSPExtension;
//import cn.tass.SRJ1933.devices.params.response.asym.AsymOperationResponse;
//import cn.tass.SRJ1933.devices.params.response.barcode.GenBarcodeResponse;
//import cn.tass.SRJ1933.devices.params.response.barcode.ParseBarcodeQRResponse;
//import cn.tass.SRJ1933.devices.params.response.cert.*;
//import cn.tass.SRJ1933.devices.params.response.digest.*;
//import cn.tass.SRJ1933.devices.params.response.envelop.RawEnvelopResponse;
//import cn.tass.SRJ1933.devices.params.response.keys.*;
//import cn.tass.SRJ1933.devices.params.response.mac.*;
//import cn.tass.SRJ1933.devices.params.response.ofd.OfdSignResponse;
//import cn.tass.SRJ1933.devices.params.response.ofd.VerifyOfdSignResponse;
//import cn.tass.SRJ1933.devices.params.response.other.CharsetConvertResponse;
//import cn.tass.SRJ1933.devices.params.response.other.HeartBeatResponse;
//import cn.tass.SRJ1933.devices.params.response.p7Envelop.*;
//import cn.tass.SRJ1933.devices.params.response.p7Sign.GetInfoFromP7SignResponse;
//import cn.tass.SRJ1933.devices.params.response.p7Sign.P7SignExternalResponse;
//import cn.tass.SRJ1933.devices.params.response.p7Sign.P7SignResponse;
//import cn.tass.SRJ1933.devices.params.response.p7Sign.VerifyP7SignResponse;
//import cn.tass.SRJ1933.devices.params.response.pdf.PdfAddImageResponse;
//import cn.tass.SRJ1933.devices.params.response.pdf.PdfSignResponse;
//import cn.tass.SRJ1933.devices.params.response.pdf.VerifyPdfSignResponse;
//import cn.tass.SRJ1933.devices.params.response.random.GenRandResponse;
//import cn.tass.SRJ1933.devices.params.response.rawSign.RawSignExternalResponse;
//import cn.tass.SRJ1933.devices.params.response.rawSign.RawSignResponse;
//import cn.tass.SRJ1933.devices.params.response.rawSign.VerifyRawSignResponse;
//import cn.tass.SRJ1933.devices.params.response.rawSign.VerifyRawsignExternalResponse;
//import cn.tass.SRJ1933.devices.params.response.seal.MakeESignResponse;
//import cn.tass.SRJ1933.devices.params.response.seal.MakeSealResponse;
//import cn.tass.SRJ1933.devices.params.response.seal.VerifyESignResponse;
//import cn.tass.SRJ1933.devices.params.response.seal.VerifySealResponse;
//import cn.tass.SRJ1933.devices.params.response.sym.SymOperationMultiFinalResponse;
//import cn.tass.SRJ1933.devices.params.response.sym.SymOperationMultiInitResponse;
//import cn.tass.SRJ1933.devices.params.response.sym.SymOperationMultiUpdateResponse;
//import cn.tass.SRJ1933.devices.params.response.sym.SymOperationResponse;
//import cn.tass.SRJ1933.devices.params.response.timestamp.GenTimeStampResponse;
//import cn.tass.SRJ1933.devices.params.response.timestamp.GetTimeStampInfoResponse;
//import cn.tass.SRJ1933.devices.params.response.timestamp.VerifyTimeStampResponse;
//import cn.tass.SRJ1933.devices.params.response.xml.GetInfoFromXmlSignResponse;
//import cn.tass.SRJ1933.devices.params.response.xml.VerifyXmlSignResponse;
//import cn.tass.SRJ1933.devices.params.response.xml.XmlSignExternalResponse;
//import cn.tass.SRJ1933.devices.params.response.xml.XmlSignResponse;
//import cn.tass.SRJ1933.devices.utis.FileUtils;
//import cn.tass.SRJ1933.devices.utis.StringUtils;
//import cn.tass.exceptions.TAException;
//import cn.tass.kits.Forms;
//import cn.tass.kits.encoders.Base64;
//
//import java.io.IOException;
//import java.io.RandomAccessFile;
//import java.text.DateFormat;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.*;
//
///**
// * 描述: 2.0接口测试
// * <p>
// *
// * @author pxw [peixinwen@tass.com.cn]
// * @version 1.0
// * @created 2020-03-09
// */
//public class TestForSignServerNew {
//
//    private static TassSignServerApi signServerApi;
//
//    private static String printFormat = "错误码[%d]\n错误消息[%s]\n接口结果： %s\n";
//
//    public static void main(String[] args) {
//        System.out.println("*********** 设备开始初始化... *********** ");
//        try {
//            String config =
//                    "{"
//                            + "[LOGGER];"
//                            + "logsw=error;logPath=./;"
//                            + "[HOST1];"
//                            + "hsmModel=SHSM;"
//                            + "host=192.168.19.133;"
//                            + "port=9081;"
//                            + "linkNum=-10;"
//                            + "sysname=QXCS;"
//                            + "signkey=nBizP669;"
//                            + "}";
//            signServerApi = TassSignServerApi.init(config);
//            if (null == signServerApi) {
//                // 初始化失败
//                System.err.println("初始化失败....");
//            }
//            System.out.println("*********** 设备初始化完成... *********** ");
//            System.out.println("*********** 请选择测试项... *********** ");
//            mainTest();
//        } catch (TAException e) {
//            System.err.println("初始化失败...");
//            e.printStackTrace();
//        }
//    }
//
//    private static void mainTest() throws TAException {
//        System.out.println("-------------- 1    裸签名相关 --------------");
//        System.out.println("-------------- 2    P7签名相关 --------------");
//        System.out.println("-------------- 3    P7数字信封相关 --------------");
//        System.out.println("-------------- 4    对称加解密相关 --------------");
//        System.out.println("-------------- 5    非对称加解密相关 --------------");
//        System.out.println("-------------- 6    摘要计算相关 --------------");
//        System.out.println("-------------- 7    随机数相关 --------------");
//        System.out.println("-------------- 8    密钥相关 --------------");
//        System.out.println("-------------- 9    证书相关 --------------");
//        System.out.println("-------------- 10   XML签名相关 --------------");
//        System.out.println("-------------- 11   其他指令 --------------");
//        System.out.println("-------------- 12   条码相关 --------------");
//        System.out.println("-------------- 13   PDF相关 --------------");
//        System.out.println("-------------- 14   MAC和HMAC计算 --------------");
//        System.out.println("-------------- 15   电子印章相关 --------------");
//        System.out.println("-------------- 16   ODF印章相关 --------------");
//        System.out.println("-------------- 17   时间戳相关 --------------");
//        System.out.println("-------------- 18   定制接口 --------------");
////        System.out.println("-------------- 15   PFX相关 --------------");
//
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    testRawSign();
//                    break;
//                case 2:
//                    testP7Sign();
//                    break;
//                case 3:
//                    testP7Envelop();
//                    break;
//                case 4:
//                    testSym();
//                    break;
//                case 5:
//                    testAsym();
//                    break;
//                case 6:
//                    testDigest();
//                    break;
//                case 7:
//                    testRandom();
//                    break;
//                case 8:
//                    testKeys();
//                    break;
//                case 9:
//                    testCert();
//                    break;
//                case 10:
//                    testXML();
//                    break;
//                case 11:
//                    testOther();
//                    break;
//                case 12:
//                    testBarcode();
//                    break;
//                case 13:
//                    testPDF();
//                    break;
//                case 14:
//                    testMACorHMAC();
//                    break;
//                case 15:
//                    testESeal();
//                    break;
//                case 16:
//                    testOFD();
//                    break;
//                case 17:
//                    testTimeStamp();
//                    break;
//                case 18:
//                    testCustom();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    private static void testRawSign() throws TAException {
//        System.out.println("****************** 裸签名测试 *****************");
//        System.out.println("****************** 1 内部密钥裸签名 *****************");
//        System.out.println("****************** 2 内部密钥裸签名全参数 *****************");
//        System.out.println("****************** 3 验证裸签名 *****************");
//        System.out.println("****************** 4 验证裸签名（全参数）*****************");
//        System.out.println("****************** 5 外部私钥明文裸签名 *****************");
//        System.out.println("****************** 6 外部私钥密文裸签名 *****************");
//        System.out.println("****************** 7 外部公钥验证签名 *****************");
//        System.out.println("****************** 0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    innerKeyRawSign();
//                    break;
//                case 2:
//                    innerKeyRawSignWholeParam();
//                    break;
//                case 3:
//                    verifyRawSign();
//                    break;
//                case 4:
//                    verifyRawSignWholeParam();
//                    break;
//                case 5:
//                    exterKeyRawSign();
//                    break;
//                case 6:
//                    exterCipherKeyRawSign();
//                    break;
//                case 7:
//                    exterKeyVerifySign();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testP7Sign() throws TAException {
//        System.out.println("****************** p7签名测试 *****************");
//        System.out.println("****************** 1 p7签名 - 内部密钥 *****************");
//        System.out.println("****************** 2 扩展p7签名 - 内部密钥 *****************");
//        System.out.println("****************** 3 p7签名 - 外部私钥明文 *****************");
//        System.out.println("****************** 4 p7签名 - 外部私钥密文 *****************");
//        System.out.println("****************** 5 验证p7签名 *****************");
//        System.out.println("****************** 6 验证p7签名（全参数） *****************");
//        System.out.println("****************** 7 获取p7签名信息 *****************");
//        System.out.println("****************** 0 返回上级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    p7SignInnerKey();
//                    break;
//                case 2:
//                    p7SignExtInnerKey();
//                    break;
//                case 3:
//                    p7SignExterkey();
//                    break;
//                case 4:
//                    p7SignExterCipherKey();
//                    break;
//                case 5:
//                    verifyP7Sign();
//                    break;
//                case 6:
//                    verifyP7Sign2();
//                    break;
//                case 7:
//                    getP7SignInfo();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//
//    }
//
//    private static void testP7Envelop() throws TAException {
//        System.out.println("******************  p7数字信封 *****************");
//        System.out.println("****************** 1 编制p7数字信封 内部密钥和内部证书 *****************");
//        System.out.println("****************** 2 解密P7数字信封（内部私钥） *****************");
//        System.out.println("****************** 3 编制P7数字信封（外部证书） *****************");
//        System.out.println("****************** 4 解密p7数字信封（外部私钥明文） *****************");
//        System.out.println("****************** 5 解密p7数字信封（外部私钥密文） *****************");
//        System.out.println("****************** 6 编制p7带签名的数字证书 - 签名使用内部密钥，加密使用内部密钥 *****************");
//        System.out.println("****************** 7 编制p7带签名的数字证书 - 外部密钥加签，加密使用内部密钥 *****************");
//        System.out.println("****************** 8 编制p7带签名的数字证书 - 外部密钥加签，加密使用外部证书 *****************");
//        System.out.println("****************** 9 编制p7带签名的数字证书 - 签名使用内部密钥，加密使用外部证书 *****************");
//        System.out.println("****************** 10 解密P7带签名数字信封 - 内部非对称解密 *****************");
//        System.out.println("****************** 11 解密P7带签名数字信封 - 外部私钥解密 可以是密文 *****************");
//        System.out.println("****************** 12 解密P7数字信封（外部证书） *****************");
//        System.out.println("****************** 0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    p7EnvelopInnerKey();
//                    break;
//                case 2:
//                    decryptEnvelopInnerKey();
//                    break;
//                case 3:
//                    p7EnvelopExter();
//                    break;
//                case 4:
//                    decryptEnvelopExter();
//                    break;
//                case 5:
//                    decryptEnvelopExterCipher();
//                    break;
//                case 6:
//                    p7EnvelopWithSign1();
//                    break;
//                case 7:
//                    p7EnvelopWithSign2();
//                    break;
//                case 8:
//                    p7EnvelopWithSign3();
//                    break;
//                case 9:
//                    p7EnvelopWithSign4();
//                    break;
//                case 10:
//                    decryptEnvelopWithSignInner();
//                    break;
//                case 11:
//                    decryptEnvelopWithSignExter();
//                    break;
//                case 12:
//                    decryptP7EnvelopByCert();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testSym() throws TAException {
//        System.out.println("******************  对称加解密 *****************");
//        System.out.println("******************  1 对称加密 - 内部密钥 *****************");
//        System.out.println("******************  2 对称加密 - 外部密钥 *****************");
//        System.out.println("******************  3 对称解密 - 内部密钥 *****************");
//        System.out.println("******************  4 对称解密 - 外部密钥，可以是明文可以是密文 *****************");
//        System.out.println("******************  5 多包加密 - 初始化 内部密钥 *****************");
//        System.out.println("******************  6 多包加密 - 初始化 外部密钥 *****************");
//        System.out.println("******************  7 多包加密 - 更新数据 *****************");
//        System.out.println("******************  8 数据多包加密 - 结束加密 *****************");
//        System.out.println("******************  9 多包数据解密 - 解密初始 *****************");
//        System.out.println("******************  10 多包数据解密 - 解密初始化 外部密钥 *****************");
//        System.out.println("******************  11 多包解密 - 更新 *****************");
//        System.out.println("******************  12 多包解密 - 结束 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    symEncrpytInner();
//                    break;
//                case 2:
//                    symEncrpytExt();
//                    break;
//                case 3:
//                    symDecryptInner();
//                    break;
//                case 4:
//                    symDecryptExt();
//                    break;
//                case 5:
//                    symEncryptInitInner();
//                    break;
//                case 6:
//                    symEncryptInitExt();
//                    break;
//                case 7:
//                    symEncryptUpdate();
//                    break;
//                case 8:
//                    symEncryptFinal();
//                    break;
//                case 9:
//                    symDecryptInitInner();
//                    break;
//                case 10:
//                    symDecryptInitExt();
//                    break;
//                case 11:
//                    symDecryptUpdate();
//                    break;
//                case 12:
//                    symDecryptFinal();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testAsym() throws TAException {
//        System.out.println("******************  非对称加解密 *****************");
//        System.out.println("******************  1 公钥加密（内部密钥） *****************");
//        System.out.println("******************  2 私钥解密 内部密钥 - 明文返回 *****************");
//        System.out.println("******************  3 私钥解密 内部密钥 - 对密钥转加密后返回 *****************");
//        System.out.println("******************  4 公钥加密，外部公钥和证书 *****************");
//        System.out.println("******************  5 私钥解密，外部明文私钥，返回数据明文 *****************");
//        System.out.println("******************  6 私钥解密，外部明文私钥，返回数据密文 *****************");
//        System.out.println("******************  7 私钥解密，外部私钥密文，返回数据明文 *****************");
//        System.out.println("******************  8 私钥解密，外部私钥密文，返回数据密文 *****************");
//        System.out.println("******************  9 公钥加密（内部密钥-对称加密转非对称加密-待加密的数据为对称密钥加密的密文） *****************");
//        System.out.println("******************  10  公钥加密（外部公钥和证书-对称加密转非对称加密-待加密的数据为对称密钥加密的密文） *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    asymEncryptInner();
//                    break;
//                case 2:
//                    asymDecryptInner1();
//                    break;
//                case 3:
//                    asymDecryptInner2();
//                    break;
//                case 4:
//                    asymEncryptExt();
//                    break;
//                case 5:
//                    asymDecryptExt1();
//                    break;
//                case 6:
//                    asymDecryptExt2();
//                    break;
//                case 7:
//                    asymDecryptExt3();
//                    break;
//                case 8:
//                    asymDecryptExt4();
//                    break;
//                case 9:
//                    asymEncryptInner1();
//                    break;
//                case 10:
//                    asymEncryptExt1();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testDigest() throws TAException {
//        System.out.println("******************  摘要计算 *****************");
//        System.out.println("******************  1 摘要计算，非国密 *****************");
//        System.out.println("******************  2 摘要计算，国密，内部非对称密钥 *****************");
//        System.out.println("******************  3 摘要计算，国密，外部证书 *****************");
//        System.out.println("******************  4 数据多包摘要 - 初始化 - 非国密 *****************");
//        System.out.println("******************  5 数据多包摘要 - 初始化 - 国密 - 内部密钥 *****************");
//        System.out.println("******************  6 数据多包摘要 - 初始化 - 国密 - 外部密钥 *****************");
//        System.out.println("******************  7 数据多包摘要 - 更新 *****************");
//        System.out.println("******************  8 数据多包摘要 - 结束 *****************");
//        System.out.println("******************  9 国密签名Z值计算 - 内部密钥 *****************");
//        System.out.println("******************  10 国密签名Z值计算 - 外部密钥 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    digest();
//                    break;
//                case 2:
//                    digestSM2Inner();
//                    break;
//                case 3:
//                    digestSM2Ext();
//                    break;
//                case 4:
//                    digestInit();
//                    break;
//                case 5:
//                    digestInitSM2Inner();
//                    break;
//                case 6:
//                    digestInitSM2Ext();
//                    break;
//                case 7:
//                    digestUpdate();
//                    break;
//                case 8:
//                    digestFinal();
//                    break;
//                case 9:
//                    sm2ZValueInner();
//                    break;
//                case 10:
//                    sm2ZValueExt();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testRandom() throws TAException {
//        System.out.println("******************  生成随机数 *****************");
//
//        int size = 16;
//        GenRandResponse genRandResponse = signServerApi.genRand(size);
//        System.out.println("生成随机数：" + String.format(printFormat, genRandResponse.getCode(), genRandResponse.getMsg(), genRandResponse.getRand()));
//
//    }
//
//    private static void testKeys() throws TAException {
//        System.out.println("******************  密钥相关 *****************");
//        System.out.println("******************  1  生成对称密钥 - 明文 *****************");
//        System.out.println("******************  2  生辰对称密钥 - 密文 *****************");
//        System.out.println("******************  3  产生非对称密钥对 - 明文 *****************");
//        System.out.println("******************  4  产生非对称密钥对 - 加密后返回 *****************");
//        System.out.println("******************  5  PrivateD私钥转换为PKCS8私钥 *****************");
//        System.out.println("******************  6  PKCS8私钥转换为PrivateD私钥 *****************");
//        System.out.println("******************  7  XY公钥转换为X509公钥 *****************");
//        System.out.println("******************  8  X509公钥转换为XY公钥 *****************");
//        System.out.println("******************  9  根据密钥标识获取非对称密钥信息 *****************");
//        System.out.println("******************  10 在加密机内产生非对称密钥对 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    genSymKey();
//                    break;
//                case 2:
//                    genSymKeyCipher();
//                    break;
//                case 3:
//                    genAsymKey();
//                    break;
//                case 4:
//                    genAsymKeyCipher();
//                    break;
//                case 5:
//                    convertPkcs8Key();
//                    break;
//                case 6:
//                    parserPkcsKey();
//                    break;
//                case 7:
//                    convertX509PubKey();
//                    break;
//                case 8:
//                    parserX509Key();
//                    break;
//                case 9:
//                    asymKeySearch();
//                    break;
//                case 10:
//                    genStandKeyPair();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testCert() throws TAException {
//        System.out.println("******************  证书相关 *****************");
//        System.out.println("******************  1  列举根证书标识 *****************");
//        System.out.println("******************  2  导出根证书 *****************");
//        System.out.println("******************  3  导入根证书 *****************");
//        System.out.println("******************  4  导出密钥对证书 *****************");
//        System.out.println("******************  5  导出业务证书 *****************");
//        System.out.println("******************  6  删除用户证书 *****************");
//        System.out.println("******************  7  导入业务证书 *****************");
//        System.out.println("******************  8  检查用户证书是否存在 *****************");
//        System.out.println("******************  9  获取证书信息 *****************");
//        System.out.println("******************  10 校验证书 *****************");
//        System.out.println("******************  11 生成证书请求 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    listRootCertIds();
//                    break;
//                case 2:
//                    exportRootCert();
//                    break;
//                case 3:
//                    importRootCert();
//                    break;
//                case 4:
//                    exportKeyPairCert();
//                    break;
//                case 5:
//                    exportUserCert();
//                    break;
//                case 6:
//                    delUserCert();
//                    break;
//                case 7:
//                    importUserCert();
//                    break;
//                case 8:
//                    existUserCert();
//                    break;
//                case 9:
//                    getCertInfo();
//                    break;
//                case 10:
//                    validateCert();
//                    break;
//                case 11:
//                    genCsr();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testXML() throws TAException {
//        System.out.println("******************  XML签名 *****************");
//        System.out.println("******************  1 编制XML签名（内部密钥） *****************");
//        System.out.println("******************  2 编制XML摘要签名（内部密钥） *****************");
//        System.out.println("******************  3 编制XML签名（外部密钥明文） *****************");
//        System.out.println("******************  4 编制XML签名（外部密钥密文） *****************");
//        System.out.println("******************  5 核验XML签名 *****************");
//        System.out.println("******************  6 获取XML签名信息 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    xmlSignInner();
//                    break;
//                case 2:
//                    xmlDigestSignInner();
//                    break;
//                case 3:
//                    xmlSignExt();
//                    break;
//                case 4:
//                    xmlSignExtCipher();
//                    break;
//                case 5:
//                    checkXmlSign();
//                    break;
//                case 6:
//                    getXmlInfo();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//
//    }
//
//    private static void testOther() throws TAException {
//        System.out.println("******************  其他指令 *****************");
//        System.out.println("******************  1 字符编码转换 *****************");
//        System.out.println("******************  2 编制裸信封（扩展） *****************");
//        System.out.println("******************  3 解密裸信封（扩展） *****************");
//        System.out.println("******************  4 心跳 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    testChangeChar();
//                    break;
//                case 2:
//                    rawEnvelopEncryptEx();
//                    break;
//                case 3:
//                    rawEnvelopDecryptEx();
//                    break;
//                case 4:
//                    heartBeat();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    private static void testChangeChar() throws TAException {
//        String srcCharSet = "utf-8";
//        String dstCharSet = "gbk";
//        String data = orgSignData;
//        CharsetConvertResponse charsetConvertResponse = signServerApi.charsetConvert(srcCharSet, dstCharSet, data);
//        System.out.println("字符编码转换：" + String.format(printFormat, charsetConvertResponse.getCode(), charsetConvertResponse.getMsg(), charsetConvertResponse.getResult()));
//
//    }
//
//    private static RawEnvelopResponse rawEnvelopEncryptEx() throws TAException {
//        //非对称解密密钥唯一id
//        String keyOrCertId = "pdsm2";
//        //0： 表示keyId为非对称密钥标识名(未传入时的默认值),1： 表示keyId为非对称密钥DN，DN信息必须进行BASE64编码
//        int keyOrCertIdType = 0;
//        //sm4加密的加密模式，可选值： 0: ECB 模式 1: CBC 模式 2：OFB 模式 3：CFB 模式 非以上可选值，默认为 ECB 模式
//        int mode = 1;
//        //sm4加密的填充模式，0：不填充 1：pkcs5 填充 非以上可选值，默认为不填充（OFB 和 CFB 加密模式下该参数不生效）
//        int padMode = 1;
//        //iv 向量，非 ECB 模式该参数必填
//        String iv = Base64.toBase64String("1111111111111111".getBytes());
//        //待加密的数据 base64编码
//        String data = Base64.toBase64String("1111111111111111".getBytes());
//        //加密会话密钥的密钥id
//        String encKeyId = "sm4";
//        //加密密钥的访问码
//        String encKeyAccessCode = "";
//        //加密密钥的加密模式,可选值： 0: ECB 模式 1: CBC 模式 2：OFB 模式 3：CFB 模式 非以上可选值，默认为 ECB 模式
//        int encMode = 0;
//        //加密密钥的加密填充模式,0：不填充 1：pkcs5 填充 非以上可选值，默认为不填充（OFB 和 CFB 加密模式下该参数不生效）
//        int encPadMode = 1;
//        //加密密钥的iv值，除ECB外的IV值
//        String encIv = "";
//        //扩展数据，原样返回
//        String extData = Base64.toBase64String("aaa".getBytes());
//        RawEnvelopResponse rawEnvelopResponse = signServerApi.rawEnvelopEncryptEx(keyOrCertId, keyOrCertIdType, mode, padMode, iv, data, extData, encKeyId, encKeyAccessCode, encMode, encPadMode, encIv);
//        if (0 != rawEnvelopResponse.getCode()) {
//            System.err.println("裸信封编制失败：" + rawEnvelopResponse.getMsg());
//        } else {
//            System.out.println("编制裸信封-内部密钥：" + String.format(printFormat, rawEnvelopResponse.getCode(), rawEnvelopResponse.getMsg(), rawEnvelopResponse.getEnvelop()));
//        }
//        return rawEnvelopResponse;
//    }
//
//    private static void rawEnvelopDecryptEx() throws TAException {
//        //非对称解密密钥唯一id
//        String keyOrCertId = "pdsm2";
//        //0： 表示keyId为非对称密钥标识名(未传入时的默认值),1： 表示keyId为非对称密钥DN，DN信息必须进行BASE64编码
//        int keyOrCertIdType = 0;
//        //sm4加密的加密模式，可选值： 0: ECB 模式 1: CBC 模式 2：OFB 模式 3：CFB 模式 非以上可选值，默认为 ECB 模式
//        int mode = 1;
//        //sm4加密的填充模式，0：不填充 1：pkcs5 填充 非以上可选值，默认为不填充（OFB 和 CFB 加密模式下该参数不生效）
//        int padMode = 1;
//        //iv 向量，非 ECB 模式该参数必填
//        String iv = Base64.toBase64String("1111111111111111".getBytes());
//        RawEnvelopResponse rawEnvelopResponse = rawEnvelopEncryptEx();
//        rawEnvelopResponse = signServerApi.rawEnvelopDecryptEx(keyOrCertId, keyOrCertIdType, "", mode, padMode, iv, rawEnvelopResponse.getEnvelop());
//        if (0 != rawEnvelopResponse.getCode()) {
//            System.err.println("解密裸信封失败：" + rawEnvelopResponse.getMsg());
//        } else {
//            System.out.println("解密裸信封-内部密钥：" + String.format(printFormat, rawEnvelopResponse.getCode(), rawEnvelopResponse.getMsg(), rawEnvelopResponse.getData()));
//        }
//    }
//
//    private static void heartBeat() throws TAException {
//        HeartBeatResponse response = signServerApi.heartBeat();
//        System.out.println("心跳：" + String.format(printFormat, response.getCode(), response.getMsg(), ""));
//    }
//
//    private static void testBarcode() throws TAException {
//        System.out.println("******************  条码相关 *****************");
//        System.out.println("******************  1 生成39条码 *****************");
//        System.out.println("******************  2 生成39条码 详细定义 *****************");
//        System.out.println("******************  3 生成128条码  *****************");
//        System.out.println("******************  4 生成128条码 详细定义 *****************");
//        System.out.println("******************  5 交叉25条码生成 *****************");
//        System.out.println("******************  6 交叉25条码生成 详细定义 *****************");
//        System.out.println("******************  7 生成库巴德条码 *****************");
//        System.out.println("******************  8 生成库巴德条码 详细定义 *****************");
//        System.out.println("******************  9 PDF417条码 *****************");
//        System.out.println("******************  10 生成二维码 *****************");
//        System.out.println("******************  11 解析二维码 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    gen39Code();
//                    break;
//                case 2:
//                    gen39AllParam();
//                    break;
//                case 3:
//                    gen128Code();
//                    break;
//                case 4:
//                    gen128CodeAllParam();
//                    break;
//                case 5:
//                    gen25Code();
//                    break;
//                case 6:
//                    gen25CodeAllParam();
//                    break;
//                case 7:
//                    genBarcodeCodabar();
//                    break;
//                case 8:
//                    genBarcodeCodabarParam();
//                    break;
//                case 9:
//                    genBarcodePDF417();
//                    break;
//                case 10:
//                    genBarcodeQR();
//                    break;
//                case 11:
//                    parseBarcodeQR();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//
//    }
//
//    private static void testPDF() throws TAException {
//        System.out.println("******************  PDF相关 *****************");
//        System.out.println("******************  1 PDF骑缝章签名（内部密钥） *****************");
//        System.out.println("******************  2 PDF骑缝章签名（内部密钥） 带签章图片等信息 *****************");
//        System.out.println("******************  3 PDF骑缝章签名（外部密钥） 明文 *****************");
//        System.out.println("******************  4 PDF骑缝章签名（外部密钥） 密文 *****************");
//        System.out.println("******************  5 pdf添加图片 *****************");
//        System.out.println("******************  6 pdf 添加骑缝图片 *****************");
//        System.out.println("******************  7 PDF签名（内部密钥） *****************");
//        System.out.println("******************  8 PDF签名（外部密钥明文） *****************");
//        System.out.println("******************  9 PDF签名（外部密钥密文） *****************");
//        System.out.println("******************  10 验证PDF签名 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    pdfAcrossSignInner();
//                    break;
//                case 2:
//                    pdfAcrossSignInnerWithImage();
//                    break;
//                case 3:
//                    pdfAcrossSignExt();
//                    break;
//                case 4:
//                    pdfAcrossSignExtCipher();
//                    break;
//                case 5:
//                    pdfAddImage();
//                    break;
//                case 6:
//                    pdfAddAcrossImage();
//                    break;
//                case 7:
//                    pdfSignInner();
//                    break;
//                case 8:
//                    pdfSignExt();
//                    break;
//                case 9:
//                    pdfSignExtCipher();
//                    break;
//                case 10:
//                    verifyPdfSign();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//
//    private static void testMACorHMAC() throws TAException {
//        System.out.println("******************  MAC和HMAC *****************");
//        System.out.println("******************  1 内部密钥计算mac *****************");
//        System.out.println("******************  2 外部明文密钥计算mac *****************");
//        System.out.println("******************  3 外部密文计算mac *****************");
//        System.out.println("******************  4 迭代计算mac 初始化 内部密钥 *****************");
//        System.out.println("******************  5 迭代计算mac 初始化 外部密钥 明文 *****************");
//        System.out.println("******************  6 迭代计算mac 初始化 外部密钥 密文 *****************");
//        System.out.println("******************  7 迭代计算mac（更新数据） *****************");
//        System.out.println("******************  8 迭代计算mac （结束） *****************");
//        System.out.println("******************  9 HMAC计算 *****************");
//        System.out.println("******************  10 迭代计算hmac 初始化 *****************");
//        System.out.println("******************  11 迭代计算hmac 更新 *****************");
//        System.out.println("******************  12 迭代计算hmac 结束 *****************");
//        System.out.println("******************  0  返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    macInner();
//                    break;
//                case 2:
//                    macExt();
//                    break;
//                case 3:
//                    macExtCipher();
//                    break;
//                case 4:
//                    macInitInner();
//                    break;
//                case 5:
//                    macInitExt();
//                    break;
//                case 6:
//                    macInitExtCipher();
//                    break;
//                case 7:
//                    macUpdate();
//                    break;
//                case 8:
//                    macFinal();
//                    break;
//                case 9:
//                    hmac();
//                    break;
//                case 10:
//                    hmacInit();
//                    break;
//                case 11:
//                    hmacUpdate();
//                    break;
//                case 12:
//                    hmacFinal();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    private static void testESeal() throws TAException {
//        System.out.println("******************  电子印章相关 *****************");
//        System.out.println("******************  1 生成电子印章(内部密钥) *****************");
//        System.out.println("******************  2 生成电子印章(外部密钥) *****************");
//        System.out.println("******************  3 验证电子印章 *****************");
//        System.out.println("******************  4 电子签章(内部密钥) *****************");
//        System.out.println("******************  5 电子签章(外部密钥) *****************");
//        System.out.println("******************  6 验证电子签章 *****************");
//        System.out.println("******************  0  返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    makeSeal();
//                    break;
//                case 2:
//                    makeSealExternal();
//                    break;
//                case 3:
//                    verifySeal();
//                    break;
//                case 4:
//                    makeESign();
//                    break;
//                case 5:
//                    makeESignExternal();
//                    break;
//                case 6:
//                    verifyESign();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//
//    }
//
//    private static void testOFD() throws TAException {
//        System.out.println("******************  OFD 相关指令 *****************");
//        System.out.println("******************  1 OFD 文件签章(内部密钥) *****************");
//        System.out.println("******************  2 OFD 文件签章(外部密钥) *****************");
//        System.out.println("******************  3 OFD 文件骑缝章签章(内部密钥) *****************");
//        System.out.println("******************  4 OFD 文件骑缝章签章(外部密钥) *****************");
//        System.out.println("******************  5 验证 OFD 文件签章 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    ofdSign();
//                    break;
//                case 2:
//                    ofdSignExternal();
//                    break;
//                case 3:
//                    ofdSignCrevice();
//                    break;
//                case 4:
//                    ofdSignExternalCrevice();
//                    break;
//                case 5:
//                    verifyOfdSign();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//
//    }
//
//    /**
//     * 时间戳相关指令测试
//     *
//     * @throws TAException
//     */
//    private static void testTimeStamp() throws TAException {
//        System.out.println("******************  时间戳 相关 *****************");
//        System.out.println("******************  1 生成时间戳 *****************");
//        System.out.println("******************  2 验证时间戳 *****************");
//        System.out.println("******************  3 获取时间戳信息 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    //生成时间戳
//                    genTimeStamp();
//                    break;
//                case 2:
//                    //验证时间戳
//                    verifyTimeStamp();
//                    break;
//                case 3:
//                    //获取时间戳信息
//                    getTimeStampInfo();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    /**
//     * 定制接口测试
//     *
//     * @throws TAException
//     */
//    private static void testCustom() throws TAException {
//        System.out.println("******************  定制接口 相关 *****************");
//        System.out.println("******************  1 银联人脸识别接口 *****************");
//        System.out.println("******************  2 POS收单刷脸付接口 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    testCUPRL();
//                    break;
//                case 2:
//                    testCUPPOS();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    /**
//     * 银联人脸识别相关接口
//     *
//     * @throws TAException
//     */
//    private static void testCUPRL() throws TAException {
//        System.out.println("******************  银联人脸识别 相关 *****************");
//        System.out.println("******************  1 银联签名 *****************");
//        System.out.println("******************  2 银联验签 *****************");
//        System.out.println("******************  3 加密key数据 *****************");
//        System.out.println("******************  4 解密key数据 *****************");
//        System.out.println("******************  5 加密敏感数据 *****************");
//        System.out.println("******************  6 解密敏感数据 *****************");
//        System.out.println("******************  7 加密生成的PinBlock *****************");
//        System.out.println("******************  8 解密PinBlock *****************");
//        System.out.println("******************  9 路由索引计算 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    CUPSignData();
//                    break;
//                case 2:
//                    CUPVerifySignData();
//                    break;
//                case 3:
//                    CUPRLEncryptKey();
//                    break;
//                case 4:
//                    CUPRLDecryptKey();
//                    break;
//                case 5:
//                    CUPRLEncryptSenInfo();
//                    break;
//                case 6:
//                    CUPRLDecryptSenInfo();
//                    break;
//                case 7:
//                    CUPRLGenPinBlock();
//                    break;
//                case 8:
//                    CUPRLParsePinBlock();
//                    break;
//                case 9:
//                    CUPRLRouteIndex();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    /**
//     * 银联签名
//     *
//     * @throws TAException
//     */
//    private static void CUPSignData() throws TAException {
//        String keyId = "tasstest_sm2";
//        String keyAccessCode = "";
//        CUPSignDataResponse response = signServerApi.CUPSignData(keyId, keyAccessCode, orgSignData);
//        System.out.println("银联签名：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//
//    }
//
//    /**
//     * 银联验签
//     *
//     * @throws TAException
//     */
//    private static void CUPVerifySignData() throws TAException {
//        String keyId = "tasstest_sm2";
//        String keyAccessCode = "";
//        CUPSignDataResponse response = signServerApi.CUPSignData(keyId, keyAccessCode, orgSignData);
//        System.out.println("银联签名：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        String certId = "tasstest_sm2";
//        if (response.getCode() == 0) {
//            CUPVerifySignDataResponse verifySignDataResponse = signServerApi.CUPVerifySignData(certId, TACryptConst.TA_S_ALG_SM3WITHSM2, orgSignData, response.getSign(), 0);
//            System.out.println("银联验签：" + String.format(printFormat, verifySignDataResponse.getCode(), verifySignDataResponse.getMsg(), verifySignDataResponse.toString()));
//        }
//    }
//
//    /**
//     * 加密key数据
//     *
//     * @throws TAException
//     */
//    private static void CUPRLEncryptKey() throws TAException {
//        String certId = "tasstest_sm2";
//        CUPRLEncryptKeyResponse response = signServerApi.CUPRLEncryptKey(certId, orgSignData, 1);
//        System.out.println("加密key数据：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//    }
//
//    /**
//     * 解密key数据
//     *
//     * @throws TAException
//     */
//    private static void CUPRLDecryptKey() throws TAException {
//        String certId = "tasstest_sm2";
//        CUPRLEncryptKeyResponse response = signServerApi.CUPRLEncryptKey(certId, orgSignData, 2);
//        System.out.println("加密key数据：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        if (response.getCode() == 0) {
//            String keyId = "tasstest_sm2";
//            String keyAccessCode = "";
//            CUPRLDecryptKeyResponse decryptKeyResponse = signServerApi.CUPRLDecryptKey(keyId, keyAccessCode, response.getEncrypt(), 2);
//            System.out.println("解密key数据：" + String.format(printFormat, decryptKeyResponse.getCode(), decryptKeyResponse.getMsg(), decryptKeyResponse.toString()));
//        }
//    }
//
//    /**
//     * 加密敏感信息
//     *
//     * @throws TAException
//     */
//    private static void CUPRLEncryptSenInfo() throws TAException {
//        String encKey = "cG+r+qEkocDZF28GrPMJpw==";
//        int encKeyValueType = 5;
//        String iv = Base64.toBase64String(Forms.hexStringToByte("00000000000000000000000000000000"));
//        CUPRLEncryptSenInfoResponse response = signServerApi.CUPRLEncryptSenInfo(encKey, encKeyValueType, TACryptConst.TA_ALG_SM4, iv, orgSignData, 1);
//        System.out.println("加密敏感信息：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//    }
//
//    /**
//     * 解密敏感信息
//     *
//     * @throws TAException
//     */
//    private static void CUPRLDecryptSenInfo() throws TAException {
//        String encKey = "cG+r+qEkocDZF28GrPMJpw==";
//        int encKeyValueType = 5;
//        String iv = Base64.toBase64String(Forms.hexStringToByte("00000000000000000000000000000000"));
//        CUPRLEncryptSenInfoResponse response = signServerApi.CUPRLEncryptSenInfo(encKey, encKeyValueType, TACryptConst.TA_ALG_SM4, iv, orgSignData, 1);
//        System.out.println("加密敏感信息：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        if (response.getCode() == 0) {
//            CUPRLDecryptSenInfoResponse decryptSenInfoResponse = signServerApi.CUPRLDecryptSenInfo(encKey, encKeyValueType, TACryptConst.TA_ALG_SM4, iv, response.getResult(), 1);
//            System.out.println("解密敏感信息：" + String.format(printFormat, decryptSenInfoResponse.getCode(), decryptSenInfoResponse.getMsg(), decryptSenInfoResponse.toString()));
//        }
//    }
//
//    /**
//     * 加密PINblock
//     *
//     * @throws TAException
//     */
//    private static void CUPRLGenPinBlock() throws TAException {
//        String certId = "tasstest_sm2";
//        String pinBlockAccount = Base64.toBase64String("abcdefghijklmnabcdefghijklmn".getBytes());
//        String pinBlockPin = Base64.toBase64String("abc".getBytes());
//        CUPRLGenPinBlockResponse response = signServerApi.CUPRLGenPinBlock(certId, pinBlockAccount, pinBlockPin);
//        System.out.println("加密PINblock：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//    }
//
//    /**
//     * 解密PINblock
//     *
//     * @throws TAException
//     */
//    private static void CUPRLParsePinBlock() throws TAException {
//        String certId = "tasstest_sm2";
//        String pinBlockAccount = Base64.toBase64String("abcdefghijklmnabcdefghijklmn".getBytes());
//        String pinBlockPin = Base64.toBase64String("abc".getBytes());
//        CUPRLGenPinBlockResponse response = signServerApi.CUPRLGenPinBlock(certId, pinBlockAccount, pinBlockPin);
//        System.out.println("加密PINblock：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        if (response.getCode() == 0) {
//            String keyId = "tasstest_sm2";
//            String keyAccessCode = "";
//            CUPRLParsePinBlockResponse parsePinBlockResponse = signServerApi.CUPRLParsePinBlock(keyId, keyAccessCode, response.getPinBlock(), pinBlockAccount);
//            System.out.println("解密PINblock：" + String.format(printFormat, parsePinBlockResponse.getCode(), parsePinBlockResponse.getMsg(), parsePinBlockResponse.toString()));
//        }
//    }
//
//    /**
//     * 计算路由索引
//     *
//     * @throws TAException
//     */
//    private static void CUPRLRouteIndex() throws TAException {
//        String pinBlockPin = Base64.toBase64String("abc".getBytes());
//        String signTime = Base64.toBase64String("2022-08-30 12:30:00".getBytes());
//        String encKey = "cG+r+qEkocDZF28GrPMJpw==";
//        CUPRLRouteIndexResponse routeIndexResponse = signServerApi.CUPRLRouteIndex(pinBlockPin, signTime, encKey, 5);
//        System.out.println("计算路由索引：" + String.format(printFormat, routeIndexResponse.getCode(), routeIndexResponse.getMsg(), routeIndexResponse.toString()));
//    }
//
//    /**
//     * POS收单刷脸付接口
//     *
//     * @throws TAException
//     */
//    private static void testCUPPOS() throws TAException {
//        System.out.println("******************  POS收单刷脸付 相关 *****************");
//        System.out.println("******************  1 签名 *****************");
//        System.out.println("******************  2 验签 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    cup_SignDataEx();
//                    break;
//                case 2:
//                    cup_verifySignDataEx();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }
//
//    /**
//     * POS收单刷脸付签名
//     *
//     * @throws TAException
//     */
//    private static void cup_SignDataEx() throws TAException {
//        String keyId = "tasstest_sm2";
//        CUPSignDataExResponse response = signServerApi.cup_SignDataEx(keyId, Base64.decode(orgSignData), "");
//        System.out.println("POS收单刷脸付签名：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//    }
//
//    /**
//     * POS收单刷脸付验签
//     *
//     * @throws TAException
//     */
//    private static void cup_verifySignDataEx() throws TAException {
//        String keyId = "tasstest_sm2";
//        CUPSignDataExResponse response = signServerApi.cup_SignDataEx(keyId, Base64.decode(orgSignData), "");
//        System.out.println("POS收单刷脸付签名：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        if (response.getCode() == 0) {
//            CUPVerifySignDataExResponse verifySignDataExResponse = signServerApi.cup_verifySignDataEx(keyId, Base64.decode(orgSignData), response.getSign());
//            System.out.println("POS收单刷脸付验签：" + String.format(printFormat, verifySignDataExResponse.getCode(), verifySignDataExResponse.getMsg(), verifySignDataExResponse.toString()));
//        }
//    }
///*    private static void testPFX() throws TAException {
//        System.out.println("******************  pfx相关 *****************");
//        System.out.println("******************  1 生成PFX文件，明文密钥 *****************");
//        System.out.println("******************  2 生成PFX文件，密文密钥 *****************");
//        System.out.println("******************  3 解析PFX文件，返回私钥明文 *****************");
//        System.out.println("******************  4 解析PFX文件，返回私钥密文 *****************");
//        System.out.println("******************  0 返回上一级 *****************");
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            switch (scanner.nextInt()) {
//                case 1:
//                    genPfx();
//                    break;
//                case 2:
//                    genPfxCipher();
//                    break;
//                case 3:
//                    parsePfx();
//                    break;
//                case 4:
//                    parsePfxCipher();
//                    break;
//                default:
//                    mainTest();
//                    break;
//            }
//        }
//    }*/
//
//    /*private static GenPfxResponse genPfx() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String password = "123456";
//        GenPfxResponse genPfxResponse = signServerApi.genPfx(privKey, cert, password);
//        System.out.println("生成pfx文件：" + String.format(printFormat, genPfxResponse.getCode(), genPfxResponse.getMsg(), genPfxResponse.getPfx()));
//        return genPfxResponse;
//    }
//
//    private static GenPfxResponse genPfxCipher() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String password = "123456";
//        GenPfxResponse genPfxResponse = signServerApi.genPfx(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, cert, password);
//        System.out.println("生成pfx文件 密钥密文：" + String.format(printFormat, genPfxResponse.getCode(), genPfxResponse.getMsg(), genPfxResponse.getPfx()));
//        return genPfxResponse;
//    }
//
//    private static void parsePfxCipher() throws TAException {
//        String pfx = genPfx().getPfx();
//        String password = "123456";
//        ParsePfxResponse parsePfxResponse = signServerApi.parsePfx(pfx, password);
//        System.out.println("解析pfx文件，明文：" + String.format(printFormat, parsePfxResponse.getCode(), parsePfxResponse.getMsg(), parsePfxResponse.toString()));
//    }
//
//    private static void parsePfx() throws TAException {
//        String pfx = genPfxCipher().getPfx();
//        String password = "123456";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        ParsePfxResponse parsePfxResponse = signServerApi.parsePfx(pfx, password, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv);
//        System.out.println("解析pfx文件，密文：" + String.format(printFormat, parsePfxResponse.getCode(), parsePfxResponse.getMsg(), parsePfxResponse.toString()));
//
//    }*/
//
//    ///////////////////////////////////////////////////////////////////////////
//    // mac计算
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static void macInner() throws TAException {
//        String data = orgSignData;
//        String keyId = "sm1";
//        String keyAccessCode = "";
//        String iv = "";
//        MacResponse mac = signServerApi.mac(data, keyId, keyAccessCode, iv, false);
//        System.out.println("内部密钥计算mac：" + String.format(printFormat, mac.getCode(), mac.getMsg(), mac.getMac()));
//    }
//
//    private static void macExt() throws TAException {
//        String data = orgSignData;
//        String extKeyInfo = "7Y3GgI1gv62W6mtkGPHP0Q==";
//        String extKeyInfoAlg = TACryptConst.TA_ALG_SM4;
//        boolean isISO9797Alg3 = false;
//        String iv = "";
//        MacResponse mac = signServerApi.mac(data, extKeyInfo, extKeyInfoAlg, isISO9797Alg3, iv);
//        System.out.println("外部明文密钥计算mac：" + String.format(printFormat, mac.getCode(), mac.getMsg(), mac.getMac()));
//    }
//
//    private static void macExtCipher() throws TAException {
//        String data = orgSignData;
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = TACryptConst.TA_ALG_SM4;
//        boolean isISO9797Alg3 = false;
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String iv = "";
//        MacResponse mac = signServerApi.mac(data, extKeyInfo, extKeyInfoAlg, isISO9797Alg3, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, iv);
//        System.out.println("外部密文密钥计算mac：" + String.format(printFormat, mac.getCode(), mac.getMsg(), mac.getMac()));
//
//    }
//
//    private static MacInitResponse macInitInner() throws TAException {
//        String keyId = "sm1";
//        String keyAccessCode = "";
//        boolean isISO9797Alg3 = false;
//        String iv = "";
//        MacInitResponse macInitResponse = signServerApi.macInit(keyId, keyAccessCode, isISO9797Alg3, iv);
//        System.out.println("计算mac初始化：" + String.format(printFormat, macInitResponse.getCode(), macInitResponse.getMsg(), macInitResponse.getMacHandle()));
//        return macInitResponse;
//    }
//
//    private static void macInitExt() throws TAException {
//        String extKeyInfo = "7Y3GgI1gv62W6mtkGPHP0Q==";
//        String extKeyInfoAlg = TACryptConst.TA_ALG_SM4;
//        boolean isISO9797Alg3 = false;
//        String iv = "";
//        MacInitResponse macInitResponse = signServerApi.macInitExt(extKeyInfo, extKeyInfoAlg, isISO9797Alg3, iv);
//        System.out.println("计算mac初始化 外部密钥明文：" + String.format(printFormat, macInitResponse.getCode(), macInitResponse.getMsg(), macInitResponse.getMacHandle()));
//    }
//
//    private static MacInitResponse macInitExtCipher() throws TAException {
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = TACryptConst.TA_ALG_SM4;
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        boolean isISO9797Alg3 = false;
//        String iv = "";
//        MacInitResponse macInitResponse = signServerApi.macInitExtCipher(extKeyInfo, extKeyInfoAlg, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, isISO9797Alg3, iv);
//        System.out.println("计算mac初始化 外部密钥密文：" + String.format(printFormat, macInitResponse.getCode(), macInitResponse.getMsg(), macInitResponse.getMacHandle()));
//        return macInitResponse;
//    }
//
//    private static MacUpdateResponse macUpdate() throws TAException {
//        String macHandle = macInitExtCipher().getMacHandle();
//        String data = orgSignData;
//        MacUpdateResponse macUpdateResponse = signServerApi.macUpdate(macHandle, data);
//        System.out.println("计算mac更新：" + String.format(printFormat, macUpdateResponse.getCode(), macUpdateResponse.getMsg(), macUpdateResponse.getMacHandle()));
//        return macUpdateResponse;
//    }
//
//    private static void macFinal() throws TAException {
//        String macHandle = macUpdate().getMacHandle();
//        MacFinalResponse macFinalResponse = signServerApi.macFinal(macHandle);
//        System.out.println("计算mac结束：" + String.format(printFormat, macFinalResponse.getCode(), macFinalResponse.getMsg(), macFinalResponse.getMac()));
//    }
//
//    private static void hmac() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_MD5;
//        String key = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String data = orgSignData;
//        HMacResponse hmac = signServerApi.hmac(algorithm, key, data);
//        System.out.println("计算hmac：" + String.format(printFormat, hmac.getCode(), hmac.getMsg(), hmac.getHmac()));
//    }
//
//    private static HMacInitResponse hmacInit() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_MD5;
//        String key = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        HMacInitResponse hMacInitResponse = signServerApi.hmacInit(algorithm, key);
//        System.out.println("计算hmac初始化：" + String.format(printFormat, hMacInitResponse.getCode(), hMacInitResponse.getMsg(), hMacInitResponse.getHmacHandle()));
//        return hMacInitResponse;
//    }
//
//    private static HMacUpdateResponse hmacUpdate() throws TAException {
//        String hmacHandle = hmacInit().getHmacHandle();
//        String data = orgSignData;
//        HMacUpdateResponse hMacUpdateResponse = signServerApi.hmacUpdate(hmacHandle, data);
//        System.out.println("计算hmac更新：" + String.format(printFormat, hMacUpdateResponse.getCode(), hMacUpdateResponse.getMsg(), hMacUpdateResponse.getHmacHandle()));
//        return hMacUpdateResponse;
//    }
//
//    private static void hmacFinal() throws TAException {
//        String hmacHandle = hmacUpdate().getHmacHandle();
//        HMacFinalResponse hMacFinalResponse = signServerApi.hmacFinal(hmacHandle);
//        System.out.println("计算hmac结束：" + String.format(printFormat, hMacFinalResponse.getCode(), hMacFinalResponse.getMsg(), hMacFinalResponse.getHmac()));
//
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // pdf
//    ///////////////////////////////////////////////////////////////////////////
//
//    //private static String pdf = Base64.toBase64String(FileUtils.getBytesByFile("./test20210702.pdf"));
//    //private static String pdf = "";
//    //提交代码的时候以下这个不提交
//    private static String pdf = Base64.toBase64String(FileUtils.getBytesByFile("./47.pdf"));
//
//    private static String pdfStamp = Base64.toBase64String(FileUtils.getBytesByFile("./test.png"));
//    //private static String pdfStamp = "";
//    //提交代码的时候以下这个不提交
//    //private static String pdfStamp = "";
//    //Base64.toBase64String(FileUtils.getBytesByFile("./stamp.png"));
//
//    private static void pdfAcrossSignInner() throws TAException {
//        String pdfPassword = "";
//        String keyId = "tasstest_sm2";
//        String stamp = pdfStamp;
//        int keyIdType = 0;
//        String signField = "field";
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        boolean checkCert = true;
//        boolean isIncludeRootCert = true;
//        int width = 100;
//        int height = 100;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfAcrossSign(pdf, stamp, pdfPassword, keyId, keyIdType, keyAccessCode, algorithm, checkCert, isIncludeRootCert, width, height, signField,
//                isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("骑缝章签名，内部密钥，不带图片：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//    }
//
//    private static void pdfAcrossSignInnerWithImage() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "no";
//        String location = "default";
//        String signField = "field";
//        boolean checkCert = true;
//        boolean isIncludeRootCert = true;
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        int width = 100;
//        int height = 100;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfAcrossSign(pdf, pdfPassword, stamp, reason, location, signField, checkCert, isIncludeRootCert, keyId, keyIdType, keyAccessCode, algorithm,
//                width, height, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("骑缝章签名，内部密钥，带图片：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//    }
//
//    private static void pdfAcrossSignExt() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "no reason";
//        String location = "default";
//        String signField = "field";
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String rootCert = "MIIBljCCATygAwIBAgIGAWWIbwE4MAoGCCqBHM9VAYN1MBIxEDAOBgNVBAMMB3NtMnJvb3QwIhgPMjAxODA4MzAwMTI1MDBaGA8yMDIzMDgzMDAxMjUwMFowEjEQMA4GA1UEAwwHc20ycm9vdDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABCYVHiqZQuSNnXaMIf10JO7TxVmrnuaDFZRLUoGn+cdoxEOtdkc1T6EevCfyGKV7UhevKTux/GT7lZLYBWDBHGKBCwBDTj1zbTJyb290ggsAQ049c20ycm9vdKNgMF4wCwYDVR0PBAQDAgCGMA8GA1UdEwQIMAYBAf8CAQEwHwYDVR0jBBgwFoAU26p8jjO3pELUIoIhwbZthp4J9pMwHQYDVR0OBBYEFNuqfI4zt6RC1CKCIcG2bYaeCfaTMAoGCCqBHM9VAYN1A0gAMEUCIGvvPjvyIfNHyaJCHPU5ZjzSfoV97XEujO0M5CNcDM+DAiEAoZFbYUM7xl8LMYjHkJZAkw071U+aDvateegUMMVbfpA=";
//        int width = 100;
//        int height = 100;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfAcrossSignExternal(pdf, pdfPassword, stamp, reason, location, signField, privKey, algorithm, cert, rootCert, width, height, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("骑缝章签名，外部密钥，明文：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//    }
//
//    private static void pdfAcrossSignExtCipher() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "reason";
//        String location = "default";
//        String signField = "field";
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        //"xE4K53xq7Sp5SVmITpXOPrqMkiub16oe1ttOJVK9YIOAt2jlnYDqGCs0IIwS28HMHXZz+V/fD3i8Brn+Tonix+0KMd8F2v7zKJKa1OySx/mKxPNVSpl5tEu4WSFD1WYBI4NiCFiFdhiM6w3SmTS+pRj5TgFIgKmmMGBZhcRBPsnKiOAXAQDI8/981pS1FxhfHWgvVQaNFrMFatUOV4ZwVO4dLc7ctgsCqdp+tVhRFDIItAeQ0spy74fRMXQifldqF8FBgW9yyL/NcN4Wc/J+UJczGZ5GX7VWNU2UO8Jc++2/8uLH7TyKFGBHMB41DFQh0CTo+KzU2fUUYll3VK93rIG7vtEMhGzTEfIfbnNw73R+K9qlawTYwGxFfgShtSuJlw6dE8S9Ku+zdgZxVgfqSyUjmzplCh/xtKIltwGyxNNvC1NkWVHvxXij7TMMVIIWVxHbMJzXGXAOJlxmVI5IbLHBQ8umUj/xGsVHFaC1YYQAkkzyEesP200qhmLh/lpT/9fJ2r+SxatOaM1HPLXld7BsF10qksQ43zRUKTEW/AHND5fVH3UO75qMOxcxkHpCjQm1Xw5iGDV03fDBg3dEjJYJJNhVjoteDvgnjKP9q4v13GaO2QrHRn/eiiwfo2UDdakCQChXZLWN8iitjW7/KzkmYjLuYu78RWFil1yafbyK0x8LDF2UVo7rSBHayUSk9TYF+/ETYqNUbp33qaT3R6bYkC+fK0vtzz0zajCUYhb2zqnS407x+mGKjD5xlIB3i3lHzd1RQFbcY0k97fZXx489LKPDFLiZVCJl/to+UaBZJbmJDg1VAY+vcgAWV8yM63gK7ktxMPvC4Sv7XO1BaQ==";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String rootCert = "MIIBljCCATygAwIBAgIGAWWIbwE4MAoGCCqBHM9VAYN1MBIxEDAOBgNVBAMMB3NtMnJvb3QwIhgPMjAxODA4MzAwMTI1MDBaGA8yMDIzMDgzMDAxMjUwMFowEjEQMA4GA1UEAwwHc20ycm9vdDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABCYVHiqZQuSNnXaMIf10JO7TxVmrnuaDFZRLUoGn+cdoxEOtdkc1T6EevCfyGKV7UhevKTux/GT7lZLYBWDBHGKBCwBDTj1zbTJyb290ggsAQ049c20ycm9vdKNgMF4wCwYDVR0PBAQDAgCGMA8GA1UdEwQIMAYBAf8CAQEwHwYDVR0jBBgwFoAU26p8jjO3pELUIoIhwbZthp4J9pMwHQYDVR0OBBYEFNuqfI4zt6RC1CKCIcG2bYaeCfaTMAoGCCqBHM9VAYN1A0gAMEUCIGvvPjvyIfNHyaJCHPU5ZjzSfoV97XEujO0M5CNcDM+DAiEAoZFbYUM7xl8LMYjHkJZAkw071U+aDvateegUMMVbfpA=";
//        int width = 100;
//        int height = 100;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfAcrossSignExternal(pdf, pdfPassword, stamp, reason, location, signField, privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, algorithm, cert,
//                rootCert, width, height, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("骑缝章签名，外部密钥，密文：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//    }
//
//    private static void pdfAddImage() throws TAException {
//        String pdfPassword = "";
//        String image = pdfStamp;
//        int x = 200;
//        int y = 200;
//        int pageNum = 1;
//        int width = 100;
//        int height = 100;
//        PdfAddImageResponse pdfAddImageResponse = signServerApi.pdfAddImage(pdf, pdfPassword, image, x, y, pageNum, width, height);
//        System.out.println("pdf添加图片：" + String.format(printFormat, pdfAddImageResponse.getCode(), pdfAddImageResponse.getMsg(), pdfAddImageResponse.getPdf()));
//    }
//
//    private static void pdfAddAcrossImage() throws TAException {
//        String pdfPassword = "";
//        String image = pdfStamp;
//        int width = 100;
//        int height = 100;
//        PdfAddImageResponse pdfAddImageResponse = signServerApi.pdfAddAcrossImage(pdf, pdfPassword, image, width, height);
//        System.out.println("pdf添加骑缝图片：" + String.format(printFormat, pdfAddImageResponse.getCode(), pdfAddImageResponse.getMsg(), pdfAddImageResponse.getPdf()));
//
//    }
//
//    private static void pdfSignInner() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "no reason";
//        String location = "default";
//        String signField = "field";
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        int x = 100;
//        int y = 100;
//        int x2 = 100;
//        int y2 = 100;
//        int pageNum = 1;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfSign(pdf, pdfPassword, stamp, reason, location, signField, keyId, keyIdType, keyAccessCode, algorithm, x, y, x2, y2, pageNum, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        // 保存数据
//        FileUtils.getFileByBytes(Base64.decode(pdfSignResponse.getSignPdf()), "./", "2.pdf");
//        System.out.println("pdf签名，内部密钥：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//    }
//
//    private static PdfSignResponse pdfSignExt() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "no reason";
//        String location = "default";
//        String signField = "field";
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String rootCert = "MIIBljCCATygAwIBAgIGAWWIbwE4MAoGCCqBHM9VAYN1MBIxEDAOBgNVBAMMB3NtMnJvb3QwIhgPMjAxODA4MzAwMTI1MDBaGA8yMDIzMDgzMDAxMjUwMFowEjEQMA4GA1UEAwwHc20ycm9vdDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABCYVHiqZQuSNnXaMIf10JO7TxVmrnuaDFZRLUoGn+cdoxEOtdkc1T6EevCfyGKV7UhevKTux/GT7lZLYBWDBHGKBCwBDTj1zbTJyb290ggsAQ049c20ycm9vdKNgMF4wCwYDVR0PBAQDAgCGMA8GA1UdEwQIMAYBAf8CAQEwHwYDVR0jBBgwFoAU26p8jjO3pELUIoIhwbZthp4J9pMwHQYDVR0OBBYEFNuqfI4zt6RC1CKCIcG2bYaeCfaTMAoGCCqBHM9VAYN1A0gAMEUCIGvvPjvyIfNHyaJCHPU5ZjzSfoV97XEujO0M5CNcDM+DAiEAoZFbYUM7xl8LMYjHkJZAkw071U+aDvateegUMMVbfpA=";
//        int x = 100;
//        int y = 100;
//        int x2 = 100;
//        int y2 = 100;
//        int pageNum = 1;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfSignExternal(pdf, pdfPassword, stamp, reason, location, signField, privKey, algorithm, cert, rootCert, x, y, x2, y2, pageNum, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("pdf签名，外部密钥明文：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//        return pdfSignResponse;
//    }
//
//    private static void pdfSignExtCipher() throws TAException {
//        String pdfPassword = "";
//        String stamp = pdfStamp;
//        String reason = "no reason";
//        String location = "default";
//        String signField = "field";
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String encKeyId = "";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String rootCert = "MIIBljCCATygAwIBAgIGAWWIbwE4MAoGCCqBHM9VAYN1MBIxEDAOBgNVBAMMB3NtMnJvb3QwIhgPMjAxODA4MzAwMTI1MDBaGA8yMDIzMDgzMDAxMjUwMFowEjEQMA4GA1UEAwwHc20ycm9vdDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABCYVHiqZQuSNnXaMIf10JO7TxVmrnuaDFZRLUoGn+cdoxEOtdkc1T6EevCfyGKV7UhevKTux/GT7lZLYBWDBHGKBCwBDTj1zbTJyb290ggsAQ049c20ycm9vdKNgMF4wCwYDVR0PBAQDAgCGMA8GA1UdEwQIMAYBAf8CAQEwHwYDVR0jBBgwFoAU26p8jjO3pELUIoIhwbZthp4J9pMwHQYDVR0OBBYEFNuqfI4zt6RC1CKCIcG2bYaeCfaTMAoGCCqBHM9VAYN1A0gAMEUCIGvvPjvyIfNHyaJCHPU5ZjzSfoV97XEujO0M5CNcDM+DAiEAoZFbYUM7xl8LMYjHkJZAkw071U+aDvateegUMMVbfpA=";
//        int x = 100;
//        int y = 100;
//        int x2 = 100;
//        int y2 = 100;
//        int pageNum = 1;
//        boolean isIncludeTimeStamp = false;
//        int timeStampType = 0;
//        String policy = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        PdfSignResponse pdfSignResponse = signServerApi.pdfSignExternal(pdf, pdfPassword, stamp, reason, location, signField, privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, algorithm, cert,
//                rootCert, x, x2, y, y2, pageNum, isIncludeTimeStamp, timeStampType, policy, isReturnCertInfo, infoType);
//        System.out.println("pdf签名，外部密钥密文：" + String.format(printFormat, pdfSignResponse.getCode(), pdfSignResponse.getMsg(), pdfSignResponse.toString()));
//
//    }
//
//    private static void verifyPdfSign() throws TAException {
//        String signPdf = pdfSignExt().getSignPdf();
//        String signpdfPassword = "";
//        int verifyLevel = 1;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyPdfSignResponse verifyPdfSignResponse = signServerApi.verifyPdfSign(signPdf, signpdfPassword, verifyLevel, isReturnCertInfo, infoType);
//        System.out.println("验证pdf签名：" + String.format(printFormat, verifyPdfSignResponse.getCode(), verifyPdfSignResponse.getMsg(), verifyPdfSignResponse.toString()));
//
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 条码相关
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static void gen39Code() throws TAException {
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        int imageFormat = 0;
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcode39(data, imageFormat);
//        System.out.println("生成39code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static void gen39AllParam() throws TAException {
//        double barHeight = 10.0;
//        double moduleWidth = 0.21;
//        double quietZoneWidth = 2.1;
//        boolean displayHumanReadable = false;
//        int dpiVal = 300;
//        boolean addCheckSUM = false;
//        double wideFactor = 2.0;
//        boolean displayStartStop = false;
//        String data = orgSignData;
//        int imageFormat = 1;
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcode39(barHeight, moduleWidth, quietZoneWidth, displayHumanReadable, dpiVal, addCheckSUM, wideFactor, displayStartStop, data, imageFormat);
//        System.out.println("生成39code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//
//    }
//
//    private static void gen128Code() throws TAException {
//        int imageFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcode128(imageFormat, data);
//        System.out.println("生成39code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static void gen128CodeAllParam() throws TAException {
//        double barHeight = 10.0;
//        double moduleWidth = 0.21;
//        double quietZoneWidth = 2.1;
//        boolean displayHumanReadable = false;
//        int dpiVal = 300;
//        int imageFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcode128(barHeight, moduleWidth, quietZoneWidth, displayHumanReadable, dpiVal, imageFormat, data);
//        System.out.println("生成39code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static void gen25Code() throws TAException {
//        int imageFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodeInter25(imageFormat, data);
//        System.out.println("生成25code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//
//    }
//
//    private static void gen25CodeAllParam() throws TAException {
//        double barHeight = 10.0;
//        double moduleWidth = 0.21;
//        double quietZoneWidth = 2.0;
//        boolean displayHumanReadable = false;
//        int imageFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        int dpiVal = 300;
//        boolean addCheckSUM = false;
//        double wideFactor = 2.0;
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodeInter25(barHeight, moduleWidth, quietZoneWidth, displayHumanReadable, imageFormat, data, dpiVal, addCheckSUM, wideFactor);
//        System.out.println("生成25code：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//
//    }
//
//    private static void genBarcodeCodabar() throws TAException {
//        int imageFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodeCodabar(imageFormat, data);
//        System.out.println("生成库巴德条码：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static void genBarcodeCodabarParam() throws TAException {
//        double barHeight = 10.0;
//        double moduleWidth = 0.21;
//        double quietZoneWidth = 2.0;
//        boolean displayHumanReadable = false;
//        int imageFormat = 0;
//        int dpiVal = 300;
//        double wideFactor = 2.0;
//        boolean displayStartStop = false;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodeCodabar(barHeight, moduleWidth, quietZoneWidth, displayHumanReadable, imageFormat, dpiVal, wideFactor, displayStartStop, data);
//        System.out.println("生成库巴德条码：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static void genBarcodePDF417() throws TAException {
//        boolean isBinary = false;
//        int errorCorrectLevel = 0;
//        int aspectRatio = 4;
//        int moduleWidth = 2;
//        int margin = 0;
//        int returnFormat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodePDF417(isBinary, errorCorrectLevel, aspectRatio, moduleWidth, margin, returnFormat, data);
//        System.out.println("PDF417条码：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//    }
//
//    private static GenBarcodeResponse genBarcodeQR() throws TAException {
//        int encodeMode = 1;
//        int errorCorrecting = 0;
//        int barSize = 3;
//        int margin = 0;
//        int returnFromat = 0;
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//        GenBarcodeResponse genBarcodeResponse = signServerApi.genBarcodeQR(encodeMode, errorCorrecting, barSize, margin, returnFromat, data);
//        System.out.println("生成二维码：" + String.format(printFormat, genBarcodeResponse.getCode(), genBarcodeResponse.getMsg(), genBarcodeResponse.getBarcode()));
//        return genBarcodeResponse;
//    }
//
//    private static void parseBarcodeQR() throws TAException {
//        String barcode = genBarcodeQR().getBarcode();
//        ParseBarcodeQRResponse parseBarcodeQRResponse = signServerApi.parseBarcodeQR(barcode);
//        System.out.println("解析二维码：" + String.format(printFormat, parseBarcodeQRResponse.getCode(), parseBarcodeQRResponse.getMsg(), parseBarcodeQRResponse.getData()));
//
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // xml签名
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static String xmlData = "PHhtbD48YT5hYWE8L2E+PC94bWw+";
//
//    private static void xmlDigestSignInner() throws TAException {
//        byte[] xmlPlainData = Base64.decode(xmlData);
//        String keyId = "tasstest_rsa1024";
//        String result = signServerApi.xmlSignEx(xmlPlainData, keyId, "", "SHA1");
//        System.out.println("xml摘要签名，内部密钥：" + result);
//    }
//
//    private static void xmlSignInner() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        boolean checkCert = false;
//        int xmlSignType = 0;
//        String url = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        XmlSignResponse xmlSignResponse = signServerApi.xmlSign(keyId, keyIdType, keyAccessCode, algorithm, xmlData, checkCert, xmlSignType, url, isReturnCertInfo, infoType);
//        System.out.println("xml签名，内部密钥：" + String.format(printFormat, xmlSignResponse.getCode(), xmlSignResponse.getMsg(), xmlSignResponse.toString()));
//
//    }
//
//    private static void xmlSignExt() throws TAException {
//        String privKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKY/EgprRz5KW6P7PqGuBgKZIxeWcciF5VlTNiOFVWYfvas8pVbvT7ACwP1pjL66INqFi1cAqE+4WCKRlUsmeoMNgSOEJF5Px8A2eowLdFjxs+xTCg3sS34S0rYPmNKppIYCVjGGwDPM0djoTDcmn9IAMN7YJisE/nXQ04JHjGqrAgMBAAECgYBP9WvW6QwmEJuM/k18c/feDguLz8dAO+44jUYvxXRynveZwZyAeK+qJ1jtSXPxVBJzJ+IB4YYSecaiMcVNlN89Gzy1ayRBQnVkRZlR3nAUK41G4ZPUpl4VjkaycriHBp3UvG7RbJFdaVj5xaVvhOhpH1qzbroIWqBPsYm27+kgoQJBAOjfFqeSe/m0guSZdu1lmVv4ZkMICqioFHRsvDQN4sXXTUBuUbA9MnID+czAotK4Z1nG1tr1XboFHpMcuB0Y3JECQQC2wf7Dho0ghjwqqdodvcV53SCRhl49jJ/DJ45M3PmgXpIRdczKKy3GHpUsAYcSEB8lTpkomtH7VirwavBCT+F7AkBgdulfiSKqEciXAatuM8QPgRp7cf1YWCgBAnoD5iymX8W0hv53zyHycQstci8Aszq8yc1+7l1hDXXY4vCxvPbBAkEApU/rc8+0vpPNvsWvP7HV+/qSqDAD9ObL6MpSBKLpxi9lLxgAa2sNV6V4R7sGA8fDdIqZLcqFYDS8WIZS15jMGwJAalgGHkexwvuzLRqK8DsZCVDtg+Yw97Bf+xVC2UWcCxHsY6X1AZ9ky/r4sxOMHlsVYKz3t3RpQUq3Fj05fHXU6w==";
//        String cert = "MIICSzCCAbagAwIBAgIGAWVG9MnEMAsGCSqGSIb3DQEBBTASMRAwDgYDVQQDDAdyc2Fyb290MCIYDzIwMTgwODE3MDgxNjEyWhgPMjAyMzA4MTcwODE2MTJaMA4xDDAKBgNVBAMMA3JzYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAv37+sz/0CYk4FSIEaGo043+iirTygjkfA24PH/+368jwo2wiyjKU9PIK1VWb6ugwwq19qQQ59UA+YtFWnvbLiVJepu95W4jttA9s1lU012ZGbnvNlLQ3l7RQ3NoJBcJPArAvJ8u5b/amf8w7g9DxJtiehYvck/rFPmPW5OJBbpcCAwEAAYELAENOPXJzYXJvb3SCBwBjbj1yc2GjgZkwgZYwCwYDVR0PBAQDAgDAMB8GA1UdIwQYMBaAFJjCLTcNuhb4TO8v0L0Q70IG18fRMB0GA1UdDgQWBBSZpm5WBVtcCZn0M5RpdPtz/I/W5jBHBgNVHSUEQDA+BggrBgEFBQcDBAYIKwYBBQUHAwIGCisGAQQBgjcUAgIGCCsGAQUFBwMDBggrBgEFBQcDAQYIKwYBBQUHAwIwCwYJKoZIhvcNAQEFA4GBABvlpo/iDi5xWOGOvWX+wOphBqDgSamNCfVIZ5b2YS2MH+4GUierTZQfnBeiKtW+D6zXJ9ZqxCWaVvwFYYRP8X36x3376iuFfNJCtB93c2QDPd2dS6mFkDiG3/PChEXWtUSDlQt8023nUgs6lTAC8aya+EGoAo9CLfZdpdFwqCgB";
//        String algorithm = TACryptConst.TA_S_ALG_SHA1WITHRSA;
//        int xmlSignType = 0;
//        String url = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        XmlSignExternalResponse xmlSignExternalResponse = signServerApi.xmlSignExternal(privKey, cert, algorithm, xmlData, xmlSignType, url, isReturnCertInfo, infoType);
//        System.out.println("xml签名，外部密钥明文：" + String.format(printFormat, xmlSignExternalResponse.getCode(), xmlSignExternalResponse.getMsg(), xmlSignExternalResponse.toString()));
//    }
//
//    private static void xmlSignExtCipher() throws TAException {
//        String privKey = "xE4K53xq7Sp5SVmITpXOPrqMkiub16oe1ttOJVK9YIOAt2jlnYDqGCs0IIwS28HMHXZz+V/fD3i8Brn+Tonix+0KMd8F2v7zKJKa1OySx/mKxPNVSpl5tEu4WSFD1WYBI4NiCFiFdhiM6w3SmTS+pRj5TgFIgKmmMGBZhcRBPsnKiOAXAQDI8/981pS1FxhfHWgvVQaNFrMFatUOV4ZwVO4dLc7ctgsCqdp+tVhRFDIItAeQ0spy74fRMXQifldqF8FBgW9yyL/NcN4Wc/J+UJczGZ5GX7VWNU2UO8Jc++2/8uLH7TyKFGBHMB41DFQh0CTo+KzU2fUUYll3VK93rIG7vtEMhGzTEfIfbnNw73R+K9qlawTYwGxFfgShtSuJlw6dE8S9Ku+zdgZxVgfqSyUjmzplCh/xtKIltwGyxNNvC1NkWVHvxXij7TMMVIIWVxHbMJzXGXAOJlxmVI5IbLHBQ8umUj/xGsVHFaC1YYQAkkzyEesP200qhmLh/lpT/9fJ2r+SxatOaM1HPLXld7BsF10qksQ43zRUKTEW/AHND5fVH3UO75qMOxcxkHpCjQm1Xw5iGDV03fDBg3dEjJYJJNhVjoteDvgnjKP9q4v13GaO2QrHRn/eiiwfo2UDdakCQChXZLWN8iitjW7/KzkmYjLuYu78RWFil1yafbyK0x8LDF2UVo7rSBHayUSk9TYF+/ETYqNUbp33qaT3R6bYkC+fK0vtzz0zajCUYhb2zqnS407x+mGKjD5xlIB3i3lHzd1RQFbcY0k97fZXx489LKPDFLiZVCJl/to+UaBZJbmJDg1VAY+vcgAWV8yM63gK7ktxMPvC4Sv7XO1BaQ==";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String cert = "MIICSzCCAbagAwIBAgIGAWVG9MnEMAsGCSqGSIb3DQEBBTASMRAwDgYDVQQDDAdyc2Fyb290MCIYDzIwMTgwODE3MDgxNjEyWhgPMjAyMzA4MTcwODE2MTJaMA4xDDAKBgNVBAMMA3JzYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAv37+sz/0CYk4FSIEaGo043+iirTygjkfA24PH/+368jwo2wiyjKU9PIK1VWb6ugwwq19qQQ59UA+YtFWnvbLiVJepu95W4jttA9s1lU012ZGbnvNlLQ3l7RQ3NoJBcJPArAvJ8u5b/amf8w7g9DxJtiehYvck/rFPmPW5OJBbpcCAwEAAYELAENOPXJzYXJvb3SCBwBjbj1yc2GjgZkwgZYwCwYDVR0PBAQDAgDAMB8GA1UdIwQYMBaAFJjCLTcNuhb4TO8v0L0Q70IG18fRMB0GA1UdDgQWBBSZpm5WBVtcCZn0M5RpdPtz/I/W5jBHBgNVHSUEQDA+BggrBgEFBQcDBAYIKwYBBQUHAwIGCisGAQQBgjcUAgIGCCsGAQUFBwMDBggrBgEFBQcDAQYIKwYBBQUHAwIwCwYJKoZIhvcNAQEFA4GBABvlpo/iDi5xWOGOvWX+wOphBqDgSamNCfVIZ5b2YS2MH+4GUierTZQfnBeiKtW+D6zXJ9ZqxCWaVvwFYYRP8X36x3376iuFfNJCtB93c2QDPd2dS6mFkDiG3/PChEXWtUSDlQt8023nUgs6lTAC8aya+EGoAo9CLfZdpdFwqCgB";
//        String algorithm = TACryptConst.TA_S_ALG_SHA1WITHRSA;
//        int xmlSignType = 0;
//        String url = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        XmlSignExternalResponse xmlSignExternalResponse = signServerApi.xmlSignExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, cert, algorithm, xmlData, xmlSignType, url, isReturnCertInfo, infoType);
//        System.out.println("xml签名，外部密钥密文：" + String.format(printFormat, xmlSignExternalResponse.getCode(), xmlSignExternalResponse.getMsg(), xmlSignExternalResponse.toString()));
//    }
//
//    private static void checkXmlSign() throws TAException {
//        String sign = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48eG1sPjxhPmFhYTwvYT48ZHM6U2lnbmF0dXJlIHhtbG5zOmRzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjIj48ZHM6U2lnbmVkSW5mbz48ZHM6Q2Fub25pY2FsaXphdGlvbk1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnL1RSLzIwMDEvUkVDLXhtbC1jMTRuLTIwMDEwMzE1Ii8+PGRzOlNpZ25hdHVyZU1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNyc2Etc2hhMSIvPjxkczpSZWZlcmVuY2UgVVJJPSIiPjxkczpUcmFuc2Zvcm1zPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSIvPjwvZHM6VHJhbnNmb3Jtcz48ZHM6RGlnZXN0TWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI3NoYTEiLz48ZHM6RGlnZXN0VmFsdWU+UWFXay9XT3lXUXgxUVFBdzQ5YTZvNFVDa1NrPTwvZHM6RGlnZXN0VmFsdWU+PC9kczpSZWZlcmVuY2U+PC9kczpTaWduZWRJbmZvPjxkczpTaWduYXR1cmVWYWx1ZT5UQ1dkbTE4R3FyZVBnZ21OM09KUkozVUprR3JhNlltOUwwTlVjMmxVNFF2d3MyRGFhOGxRbjUrOUZJUThzWXdGL3pxWjhlaHVjYUE1DQpOc1Z2YjFEM0k4bm9YNTF4TllueWNWdUMxWFhNaFIvTkwyakFtRTVSNDJpSGNpNVdBU1ZrSDBTQ3RSb0NuNFVNcVdPNGdNOTh3Uk8yDQpyWldlVG9vMFB1R05QbEpLOEt3PTwvZHM6U2lnbmF0dXJlVmFsdWU+PGRzOktleUluZm8+PGRzOktleU5hbWU+MTZjNDI3ZmUxZTY8L2RzOktleU5hbWU+PGRzOlg1MDlEYXRhPjxkczpYNTA5Q2VydGlmaWNhdGU+TUlJQ2dEQ0NBZXVnQXdJQkFnSUdBV3hDZitIbU1Bc0dDU3FHU0liM0RRRUJDekFmTVIwd0d3WURWUVFEREJSMFlYTnpkR1Z6ZEY5eQ0KYzJGeWIyOTBNVEF5TkRBaUdBOHlNREU1TURjek1ERXdORGt6TWxvWUR6SXdNamt3TnpNd01UQTBPVE15V2pBYk1Sa3dGd1lEVlFRRA0KREJCMFlYTnpkR1Z6ZEY5eWMyRXhNREkwTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FDbVB4SUthMGMrU2x1ag0KK3o2aHJnWUNtU01YbG5ISWhlVlpVellqaFZWbUg3MnJQS1ZXNzArd0FzRDlhWXkrdWlEYWhZdFhBS2hQdUZnaWtaVkxKbnFERFlFag0KaENSZVQ4ZkFObnFNQzNSWThiUHNVd29ON0V0K0V0SzJENWpTcWFTR0FsWXhoc0F6ek5IWTZFdzNKcC9TQUREZTJDWXJCUDUxME5PQw0KUjR4cXF3SURBUUFCZ1JnQVEwNDlkR0Z6YzNSbGMzUmZjbk5oY205dmRERXdNalNDRkFCRFRqMTBZWE56ZEdWemRGOXljMkV4TURJMA0KbzRHYU1JR1hNQXdHQTFVZER3UUZBd01BLzRBd0h3WURWUjBqQkJnd0ZvQVUzeUpEZUU4aUVPM3pndUtNV2dmanN5aUdEOGt3SFFZRA0KVlIwT0JCWUVGRUJDNmdNOXc2WmI0OXRPT2tuRVZKSnB3cm05TUVjR0ExVWRKUVJBTUQ0R0NDc0dBUVVGQndNRUJnZ3JCZ0VGQlFjRA0KQWdZS0t3WUJCQUdDTnhRQ0FnWUlLd1lCQlFVSEF3TUdDQ3NHQVFVRkJ3TUJCZ2dyQmdFRkJRY0RBakFMQmdrcWhraUc5dzBCQVFzRA0KZ1lFQVhwa01PejhOMDJMMC93R3ZoMnhzeW54YmI1N1NWdlloOGVQaUNUYmJDazhud25MektkVk52RUxLRWxGS0I0eUNuUDl2ZmhKYQ0KL0U4djkrcE85VHFrY2g5N0JzVHFFZ0IwUllPa0pzbUFmWnByc09uWmFDKzNkSktBZ3NOK1RqN3k0MkxxQzlrZnF4TXN4RWR4NnlmWA0KSHVjRG9LdzNybW1yRkdJQUdSdVdGTVE9PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9kczpTaWduYXR1cmU+PC94bWw+";
//        int verifyLevel = 3;
//        boolean isReturnCert = true;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyXmlSignResponse verifyXmlSignResponse = signServerApi.verifyXmlSign(sign, verifyLevel, isReturnCert, xmlData, isReturnCertInfo, infoType);
//        System.out.println("核验xml签名：" + String.format(printFormat, verifyXmlSignResponse.getCode(), verifyXmlSignResponse.getMsg(), verifyXmlSignResponse.toString()));
//    }
//
//    private static void getXmlInfo() throws TAException {
//        String sign = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48ZGF0YT48YT5hYWFhYTwvYT48Yj5iYmJiYjwvYj48ZHM6U2lnbmF0dXJlIHhtbG5zOmRzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjIj48ZHM6U2lnbmVkSW5mbz48ZHM6Q2Fub25pY2FsaXphdGlvbk1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnL1RSLzIwMDEvUkVDLXhtbC1jMTRuLTIwMDEwMzE1Ii8+PGRzOlNpZ25hdHVyZU1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNyc2Etc2hhMSIvPjxkczpSZWZlcmVuY2UgVVJJPSIiPjxkczpUcmFuc2Zvcm1zPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSIvPjwvZHM6VHJhbnNmb3Jtcz48ZHM6RGlnZXN0TWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI3NoYTEiLz48ZHM6RGlnZXN0VmFsdWU+QzhiLzFjaUd6U051R3d1dHdjeDBzdENGUDZVPTwvZHM6RGlnZXN0VmFsdWU+PC9kczpSZWZlcmVuY2U+PC9kczpTaWduZWRJbmZvPjxkczpTaWduYXR1cmVWYWx1ZT5CcjZkTkcxOHBiZ0dTYU9wME5MSDdxY1BzQ0JLaXA5dE1YUHowdy9CREZ0a0FaRjdPOVJ0d0ZpMFplc0wzNHZVKzRuenhNMFg5THY5DQp0eUpBZXZVWjl0YzllR25ERS9nd0VhSmU4NW9NKzk0aWtPZE44aHFEMU0yVEdDNnNsaFV5Ny81b1dNKzhGTWhyazAzQ2V4ZkNNOXRpDQpkUDV4MDBMaXF4NDB0UndtRWcwPTwvZHM6U2lnbmF0dXJlVmFsdWU+PGRzOktleUluZm8+PGRzOktleU5hbWU+MTZjNDI3ZmUxZTY8L2RzOktleU5hbWU+PGRzOlg1MDlEYXRhPjxkczpYNTA5Q2VydGlmaWNhdGU+TUlJQ2dEQ0NBZXVnQXdJQkFnSUdBV3hDZitIbU1Bc0dDU3FHU0liM0RRRUJDekFmTVIwd0d3WURWUVFEREJSMFlYTnpkR1Z6ZEY5eQ0KYzJGeWIyOTBNVEF5TkRBaUdBOHlNREU1TURjek1ERXdORGt6TWxvWUR6SXdNamt3TnpNd01UQTBPVE15V2pBYk1Sa3dGd1lEVlFRRA0KREJCMFlYTnpkR1Z6ZEY5eWMyRXhNREkwTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FDbVB4SUthMGMrU2x1ag0KK3o2aHJnWUNtU01YbG5ISWhlVlpVellqaFZWbUg3MnJQS1ZXNzArd0FzRDlhWXkrdWlEYWhZdFhBS2hQdUZnaWtaVkxKbnFERFlFag0KaENSZVQ4ZkFObnFNQzNSWThiUHNVd29ON0V0K0V0SzJENWpTcWFTR0FsWXhoc0F6ek5IWTZFdzNKcC9TQUREZTJDWXJCUDUxME5PQw0KUjR4cXF3SURBUUFCZ1JnQVEwNDlkR0Z6YzNSbGMzUmZjbk5oY205dmRERXdNalNDRkFCRFRqMTBZWE56ZEdWemRGOXljMkV4TURJMA0KbzRHYU1JR1hNQXdHQTFVZER3UUZBd01BLzRBd0h3WURWUjBqQkJnd0ZvQVUzeUpEZUU4aUVPM3pndUtNV2dmanN5aUdEOGt3SFFZRA0KVlIwT0JCWUVGRUJDNmdNOXc2WmI0OXRPT2tuRVZKSnB3cm05TUVjR0ExVWRKUVJBTUQ0R0NDc0dBUVVGQndNRUJnZ3JCZ0VGQlFjRA0KQWdZS0t3WUJCQUdDTnhRQ0FnWUlLd1lCQlFVSEF3TUdDQ3NHQVFVRkJ3TUJCZ2dyQmdFRkJRY0RBakFMQmdrcWhraUc5dzBCQVFzRA0KZ1lFQVhwa01PejhOMDJMMC93R3ZoMnhzeW54YmI1N1NWdlloOGVQaUNUYmJDazhud25MektkVk52RUxLRWxGS0I0eUNuUDl2ZmhKYQ0KL0U4djkrcE85VHFrY2g5N0JzVHFFZ0IwUllPa0pzbUFmWnByc09uWmFDKzNkSktBZ3NOK1RqN3k0MkxxQzlrZnF4TXN4RWR4NnlmWA0KSHVjRG9LdzNybW1yRkdJQUdSdVdGTVE9PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9kczpTaWduYXR1cmU+PC9kYXRhPg==";
//        int infoType = 0;
//        GetInfoFromXmlSignResponse infoFromXmlSign = signServerApi.getInfoFromXmlSign(sign, infoType);
//        System.out.println("获取xml签名信息：" + String.format(printFormat, infoFromXmlSign.getCode(), infoFromXmlSign.getMsg(), infoFromXmlSign.toString()));
//
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 证书相关
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static void listRootCertIds() throws TAException {
//        ListRootCertIdsResponse listRootCertIdsResponse = signServerApi.listRootCertIds();
//        System.out.println("列举根证书标识：" + String.format(printFormat, listRootCertIdsResponse.getCode(), listRootCertIdsResponse.getMsg(), listRootCertIdsResponse.toString()));
//    }
//
//    private static void exportRootCert() throws TAException {
//        String rootCertId = "tasstest_sm2root";
//        ExportRootCertResponse exportRootCertResponse = signServerApi.exportRootCert(rootCertId);
//        System.out.println("导出根证书：" + String.format(printFormat, exportRootCertResponse.getCode(), exportRootCertResponse.getMsg(), exportRootCertResponse.getCert()));
//
//    }
//
//    private static void importRootCert() throws TAException {
//        String rootCertId = "rsaAQL";
//        String parentRootCertId = "";
//        String cert = "MIIDwTCCAqmgAwIBAgIGAXmmgxf3MA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNVBAYT\n" +
//                "AkNOMQ4wDAYDVQQKEwVHTVNTTDEQMA4GA1UECxMHUEtJL1JTQTEaMBgGA1UEAxMR\n" +
//                "TWlkZGxlQ0EgZm9yIFRlc3QwIhgPMjAyMTA1MjUxNjAwMDBaGA8yMDI2MDUyNTE2\n" +
//                "MDAwMFowaDELMAkGA1UEBhMCQ04xEDAOBgNVBAgTB0JlaWppbmcxEjAQBgNVBAcT\n" +
//                "CUNoYW5nUGluZzEPMA0GA1UEChMGQ3J5cHRvMQ0wCwYDVQQLEwRUQVNTMRMwEQYD\n" +
//                "VQQDEwp6aGhSc2FUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\n" +
//                "lziVcflfn3mhGBwhij1rrHRXolYlUhhv1EyiZGupE3yoVQGtErLN/nh/LlBNFdIb\n" +
//                "eKVW3YWugy172/p3/GQz7IhXOBbqZXFF9N11QtDZcuH2xBimUjNP+ulzZocYUHlM\n" +
//                "ametTGve5XvsD7+M2lh3ki/kOthkoDmXa772fcsl8j1MfYRec/6Ql2J2yojD4a3c\n" +
//                "/RA2CSVu1beHzbEnD5BT+BCxh9D9Qu0t6v170phEOLLek21/kSQ5IY0V/j0952Rk\n" +
//                "wvgTk5MaZk97ReePBLtfdLZWPTuLYOx9+DwDrcG1s9rBF7BckDpdQjxR1vSf+7RX\n" +
//                "AmHSeNdgF901kFf/0OOKOQIDAQABo4GJMIGGMBsGA1UdIwQUMBKAEPM0pdwpzBFm\n" +
//                "9fZik3LFb5swGQYDVR0OBBIEEKA4vW6Fl5/9Pnrr697GkS0wFQYDVR0RBA4wDIIK\n" +
//                "emhoUnNhVGVzdDAJBgNVHRMEAjAAMAsGA1UdDwQEAwIAqDAdBgNVHSUEFjAUBggr\n" +
//                "BgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBAFIw4QrXf1HOjzGH\n" +
//                "xqmFJlYBsg6l6aYeTki7WhC+PsOzTYZXzaRETldIaBaiyJTxFVZnhNg21cYOilSv\n" +
//                "ddHxRaE4wPzVptgD+5uiT8VsjDyUiCZBF0COBgnqefYUTCBqEUa0sSJF9OBxjdQB\n" +
//                "i4MDB2bv3UkYA/n8puR1O04gR7EYD9Uw50e5295qENq9tm+rCrOW2t62ATPQpV2C\n" +
//                "6HGF9YbCCvz31r/pnb6EL/lng/0e09nJByGPiZhJqNb1ijjroAA+wCOxItrtLDiA\n" +
//                "kz9DwYgM/mLlPToea25lcfgQVpYwxVM0qnTo1+tb7FYh5VvfxLfBxsIF0kI+J1pA\n" +
//                "Bx6xGng=";
//        ImportRootCertResponse importRootCertResponse = signServerApi.importRootCert(rootCertId, parentRootCertId, cert);
//        System.out.println("导入根证书：" + String.format(printFormat, importRootCertResponse.getCode(), importRootCertResponse.getMsg(), ""));
//
//    }
//
//    private static void exportKeyPairCert() throws TAException {
//        String keyId = "tasstest_sm2";
//        int certType = 0;
//        ExportKeyPairCertResponse exportKeyPairCertResponse = signServerApi.exportKeyPairCert(keyId, certType);
//        System.out.println("导出密钥对证书：" + String.format(printFormat, exportKeyPairCertResponse.getCode(), exportKeyPairCertResponse.getMsg(), exportKeyPairCertResponse.toString()));
//
//    }
//
//    private static void exportUserCert() throws TAException {
//        String certId = "Q049dGFzc3Rlc3Rfc20y";
//        int certIdType = 1;
//        boolean isSign = true;
//        ExportUserCertResponse exportUserCertResponse = signServerApi.exportUserCert(certId, certIdType, isSign);
//        System.out.println("导出业务证书：" + String.format(printFormat, exportUserCertResponse.getCode(), exportUserCertResponse.getMsg(), exportUserCertResponse.getCert()));
//
//    }
//
//    private static void delUserCert() throws TAException {
//        String certId = "aqlImportUserCert";
//        int certIdType = 2;
//        boolean isSign = false;
//        DelRootCertResponse delRootCertResponse = signServerApi.delUserCert(certId, certIdType, isSign);
//        System.out.println("删除用户证书：" + String.format(printFormat, delRootCertResponse.getCode(), delRootCertResponse.getMsg(), ""));
//
//    }
//
//    private static void importUserCert() throws TAException {
//        String certId = "aqlImportUserCert";
//        // String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String cert = "MIIDxzCCAq+gAwIBAgIGAXmmhRmpMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNVBAYT\n" +
//                "AkNOMQ4wDAYDVQQKEwVHTVNTTDEQMA4GA1UECxMHUEtJL1JTQTEaMBgGA1UEAxMR\n" +
//                "TWlkZGxlQ0EgZm9yIFRlc3QwIhgPMjAyMTA1MjUxNjAwMDBaGA8yMDI2MDUyNTE2\n" +
//                "MDAwMFowazELMAkGA1UEBhMCQ04xEDAOBgNVBAgTB0JlaWppbmcxEjAQBgNVBAcT\n" +
//                "CUNoYW5nUGluZzEPMA0GA1UEChMGQ3J5cHRvMQ0wCwYDVQQLEwRUQVNTMRYwFAYD\n" +
//                "VQQDEw16aGhSc2FDbGlUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
//                "AQEA0g17nUFNAVDFv4qVGc+NijTp0DDJDOMF81BV2yiOX7ApwRTqazc4ymU0l+xV\n" +
//                "cquVMUk4b1Vq6A5zXi0FK+qWCT/5JiYMl/CDTyfmt+IPsQ2q1W4ekPW9XXUMKSvv\n" +
//                "cfv1CkwD8lYIJHYip2ilCIyG7WMFZLsCDBR6pSrsQrXVNfL6cjXmljzdmLWl1jj9\n" +
//                "WQt0lEUOCQbbXjhHjHHb980NdR5R7J+wVqCHAYcKfKfkH8FZBgmBdfW7O2JnwUl/\n" +
//                "3TbcAjwjJnH5WbtdTiFyPN4lq9+XpBITcuVODA+3m3eMqhg5boNrOmZeN7C/1lSJ\n" +
//                "ukAFpMUlBRlhGmBKg5b9p1aREwIDAQABo4GMMIGJMBsGA1UdIwQUMBKAEPM0pdwp\n" +
//                "zBFm9fZik3LFb5swGQYDVR0OBBIEEEFZElgKXMHz0bjIuKcco6YwGAYDVR0RBBEw\n" +
//                "D4INemhoUnNhQ2xpVGVzdDAJBgNVHRMEAjAAMAsGA1UdDwQEAwIAqDAdBgNVHSUE\n" +
//                "FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEBABTIyGK9\n" +
//                "M6ERJPXb29jItqgl7wA+PyXFlh9+XUOH5cqYIQ+e+aNiIbyYySb8GFT3V6EmRA0Y\n" +
//                "qvO39626LnaK66US48JPkTDwfCPFcJw4FIbaTnJnngRouRctPPoCkFdt63e9qxTZ\n" +
//                "nMnql185nRFEXxRa8tFDIE1oCoyo1psxJHNy/STt8rmxjh58WH9IiSGC6PhCpBXu\n" +
//                "/DPRoSC58b5SHfBP+7ie/bwdfnAQvkBWaypf3S/2TIM27nt+vgqsyY2SOuPh7Y9j\n" +
//                "IwUVD7q1XurYCavnQpdjQYXy8nXh9wZkY7svEOrz/25mBqgmw/WvJSIOoh9AO8tO\n" +
//                "B7Ts1GrGu+ZUDKE=";
//        int certType = 0;
//        String rootCertId = "";
//        boolean isOverwrite = false;
//        ImportUserCertResponse importUserCertResponse = signServerApi.importUserCert(certId, cert, certType, rootCertId, isOverwrite);
//        System.out.println("导入用户证书：" + String.format(printFormat, importUserCertResponse.getCode(), importUserCertResponse.getMsg(), ""));
//
//    }
//
//    private static void existUserCert() throws TAException {
//        String certId = "test_cert";
//        int certIdType = 2;
//        boolean isSign = false;
//        boolean isValid = false;
//        ExistUserCertResponse existUserCertResponse = signServerApi.existUserCert(certId, certIdType, isSign, isValid);
//        System.out.println("检查用户证书是否存在：" + String.format(printFormat, existUserCertResponse.getCode(), existUserCertResponse.getMsg(), existUserCertResponse.isExist()));
//    }
//
//    private static void getCertInfo() throws TAException {
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        int infoType = 0;
//        GetCertInfoResponse certInfo = signServerApi.getCertInfo(cert, infoType);
//        System.out.println("获取证书信息：" + String.format(printFormat, certInfo.getCode(), certInfo.getMsg(), certInfo.toString()));
//    }
//
//    private static void validateCert() throws TAException {
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        int verifyLevel = 1;
//        ValidateCertResponse validateCertResponse = signServerApi.validateCert(cert, verifyLevel);
//        System.out.println("校验证书：" + String.format(printFormat, validateCertResponse.getCode(), validateCertResponse.getMsg(), ""));
//
//    }
//
//    private static void genCsr() throws TAException {
//        //非对称密钥标识名
//        String keyName = "genSM2CsrTest";
//        //密钥算法，1-SM2，2-RSA，3-ECC
//        int keyType = 1;
//        //证书请求类型，可选值： 0：标准证书请求(未传入时的默认值) 1：CFCA 双证请求
//        int csrType = 0;
//        //生成 RSA 密钥的模长，仅类型为 RSA 密 钥该参数有效，可支持长度：1024、2048、4096
//        int rsaModulusLen = 0;
//        //生成 ECC 密钥的曲线参数，仅类型为 ECC 密钥该参数有效，可选值： 1：secp256r1 曲线 2：brainpoolP256r1 曲线 3：FRP256v1 曲线
//        int eccCurveId = 0;
//        //请求签名算法，仅类型为 RSA 密钥该参数有效，可选值： MD5WITHRSA SHA1WITHRSA SHA256WITHRSA(未传入时的默认 值) SHA384WITHRSA SHA512WITHRSA
//        String algorithm = "";
//        //证书主题
//        String subject = "CN=genSM2CsrTest,C=CN,OU=TASS";
//        //证书主题格式，可选值： 0：Base64 编码格式(未传入时的默认值) 1：明文格式
//        int subjectFormat = 1;
//        GenCsrResponse genCsrResponse = signServerApi.genCsr(keyName, keyType, csrType, rsaModulusLen, eccCurveId, algorithm, subject, subjectFormat);
//        System.out.println("生成SM2证书请求：" + String.format(printFormat, genCsrResponse.getCode(), genCsrResponse.getMsg(), genCsrResponse.toString()));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 密钥相关
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static void genSymKey() throws TAException {
//        String algName = TACryptConst.TA_ALG_SM4;
//        int keySize = 0; // 仅对RC4有效
//        GenSymKeyResponse genSymKeyResponse = signServerApi.genSymKey(algName, keySize);
//        System.out.println("产生对称密钥，明文返回：" + String.format(printFormat, genSymKeyResponse.getCode(), genSymKeyResponse.getMsg(), genSymKeyResponse.getKey()));
//    }
//
//    private static void genSymKeyCipher() throws TAException {
//        String algName = TACryptConst.TA_ALG_SM4;
//        int keySize = 0;
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        GenSymKeyResponse genSymKeyResponse = signServerApi.genSymKey(algName, keySize, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv);
//        System.out.println("产生对称密钥，加密返回：" + String.format(printFormat, genSymKeyResponse.getCode(), genSymKeyResponse.getMsg(), genSymKeyResponse.getKey()));
//    }
//
//    private static void genAsymKey() throws TAException {
//        int keyType = 1;
//        int rsaModulusLen = 0;  // int rsaModulusLen = 1024; keyType = 2;
//        int eccCurveId = 0;     // int eccCurveId = 1; keyType = 3;
//        GenAsymKeyPairResponse genAsymKeyPairResponse = signServerApi.genAsymKeyPair(keyType, rsaModulusLen, eccCurveId);
//        System.out.println("产生非对称密钥，明文返回：" + String.format(printFormat, genAsymKeyPairResponse.getCode(), genAsymKeyPairResponse.getMsg(), genAsymKeyPairResponse.toString()));
//
//    }
//
//    private static void genAsymKeyCipher() throws TAException {
//        int keyType = 1;
//        int rsaModulusLen = 0;
//        int eccCurveId = 0;
//        String encKeyId = "sm4";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        GenAsymKeyPairResponse genAsymKeyPairResponse = signServerApi.genAsymKeyPair(keyType, rsaModulusLen, eccCurveId, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv);
//        System.out.println("产生非对称密钥，加密返回：" + String.format(printFormat, genAsymKeyPairResponse.getCode(), genAsymKeyPairResponse.getMsg(), genAsymKeyPairResponse.toString()));
//
//    }
//
//    private static void convertPkcs8Key() throws TAException {
//        String privateD = "04e2a4ba539a153e47cc98a51a0bb93927cc69f56f7d80caf11c436bad4c1287";
//        int privateKeyType = 0;
//        ConvertPkcs8KeyResponse convertPkcs8KeyResponse = signServerApi.convertPkcs8Key(privateD, privateKeyType);
//        System.out.println("PrivateD转换为PKCS8私钥：" + String.format(printFormat, convertPkcs8KeyResponse.getCode(), convertPkcs8KeyResponse.getMsg(), convertPkcs8KeyResponse.getPkcs8Key()));
//    }
//
//    private static void parserPkcsKey() throws TAException {
//        String pkcs8Key = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        ParserPkcsKeyResponse parserPkcsKeyResponse = signServerApi.parserPkcsKey(pkcs8Key);
//        System.out.println("PKCS8私钥转换为PrivateD私钥：" + String.format(printFormat, parserPkcsKeyResponse.getCode(), parserPkcsKeyResponse.getMsg(), parserPkcsKeyResponse.toString()));
//    }
//
//    private static void convertX509PubKey() throws TAException {
//        String pubKey = "BEl+TeELihxeGYQW1SeZlHsRVpWRRqAFxe3tVmngk1DoK21qFp9pEyZ1oudyldc81csnGfTqRLbHbpXgPJgQ2O4=";
//        int pubKeyType = 0;
//        ConvertX509PubKeyResponse convertX509PubKeyResponse = signServerApi.convertX509PubKey(pubKey, pubKeyType);
//        System.out.println("PKCS8私钥转换为PrivateD私钥：" + String.format(printFormat, convertX509PubKeyResponse.getCode(), convertX509PubKeyResponse.getMsg(), convertX509PubKeyResponse.getX509PubKey()));
//
//    }
//
//    private static void parserX509Key() throws TAException {
//        String pubKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7g==";
//        ParserX509KeyResponse parserX509KeyResponse = signServerApi.parserX509Key(pubKey);
//        System.out.println("X509公钥转换为XY公钥：" + String.format(printFormat, parserX509KeyResponse.getCode(), parserX509KeyResponse.getMsg(), parserX509KeyResponse.toString()));
//    }
//
//    private static void asymKeySearch() throws TAException {
//        String keyName = "tasstest_sm2";
//        AsymKeySearchResponse response = signServerApi.asymKeySearch(keyName);
//        System.out.println("查询非对称密钥的信息：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//    }
//
//    private static void genStandKeyPair() throws TAException {
//        //非对称密钥标识名
//        String keyName = "genSM2KeyByApi";
//        //密钥算法，1-SM2,2-RSA，3-ECC
//        int keyType = 1;
//        //密钥容器模式：1-单密钥，2-双密钥
//        int keyMode = 1;
//        //生成RSA密钥的模长，仅类型为RSA密钥该参数有效，可支持长度：1024、2048、4096
//        int rsaModulusLen = 0;
//        //生成 ECC密钥的曲线参数，仅类型为ECC密钥该参数有效，可选值： 1：secp256r1 曲线 2：brainpoolP256r1 曲线 3：FRP256v1 曲线
//        int eccCurveId = 0;
//        GenStandKeyPairResponse response = signServerApi.genStandKeyPair(keyName, keyType, keyMode, rsaModulusLen, eccCurveId);
//        System.out.println("在加密机内产生非对称密钥对：" + String.format(printFormat, response.getCode(), response.getMsg(), ""));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 摘要计算
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static DigestResponse digest() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SHA256;
//        String data = orgSignData;
//        DigestResponse digest = signServerApi.digest(algorithm, data);
//        System.out.println("摘要计算 非国密：" + String.format(printFormat, digest.getCode(), digest.getMsg(), digest.getDigest()));
//        return digest;
//    }
//
//    private static DigestResponse digestSM2Inner() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SM3;
//        String sm2KeyId = "tasstest_sm2";
//        int sm2KeyIdType = 0;
//        String sm2UserID = "";
//        String data = orgSignData;
//        DigestResponse digest = signServerApi.digest(algorithm, sm2KeyId, sm2KeyIdType, sm2UserID, data);
//        System.out.println("摘要计算 国密内部密钥：" + String.format(printFormat, digest.getCode(), digest.getMsg(), digest.getDigest()));
//        return digest;
//    }
//
//    private static DigestResponse digestSM2Ext() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SM3;
//        String sm2PubKeyInfo = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEhNZZgdSNOhbsUPE2Lr4qZRGVXoaYFzlPnufEO0Jfsbp3T5xQpn2LM+3JlBCUBQzYIIMGK/nCyg7i0aohRc89tw==";
//        int sm2PubKeyInfoType = 0;
//        String sm2UserID = "";
//        String data = orgSignData;
//        DigestResponse digestResponse = signServerApi.digestExtKey(algorithm, sm2PubKeyInfo, sm2PubKeyInfoType, sm2UserID, data);
//        System.out.println("摘要计算 国密外部密钥：" + String.format(printFormat, digestResponse.getCode(), digestResponse.getMsg(), digestResponse.getDigest()));
//        return digestResponse;
//    }
//
//    private static DigestInitResponse digestInit() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SHA256;
//        DigestInitResponse digestInitResponse = signServerApi.digestInit(algorithm);
//        System.out.println("摘要计算 初始化：" + String.format(printFormat, digestInitResponse.getCode(), digestInitResponse.getMsg(), digestInitResponse.getDigestHandle()));
//        return digestInitResponse;
//    }
//
//    private static DigestInitResponse digestInitSM2Inner() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SM3;
//        String sm2KeyId = "tasstest_sm2";
//        int sm2KeyIdType = 0;
//        String sm2UserID = "";
//        DigestInitResponse digestInitResponse = signServerApi.digestInitInner(algorithm, sm2KeyId, sm2KeyIdType, sm2UserID);
//        System.out.println("摘要计算 初始化(内部密钥)：" + String.format(printFormat, digestInitResponse.getCode(), digestInitResponse.getMsg(), digestInitResponse.getDigestHandle()));
//        return digestInitResponse;
//    }
//
//    private static DigestInitResponse digestInitSM2Ext() throws TAException {
//        String algorithm = TACryptConst.TA_DIGEST_SM3;
//        String sm2PubKeyInfo = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEuId8U+yGa2e0XIlbJq2qg/nX/LO+Sj60RRj8TxYSlLef8yjDgM3rDYB1SFMwRnozxGRrBo6gLrlHmunMM169vQ==";
//        int sm2PubKeyInfoType = 0;
//        String sm2UserID = "";
//        DigestInitResponse digestInitResponse = signServerApi.digestInitExterKey(algorithm, sm2PubKeyInfo, sm2PubKeyInfoType, sm2UserID);
//        System.out.println("摘要计算 初始化(外部证书)：" + String.format(printFormat, digestInitResponse.getCode(), digestInitResponse.getMsg(), digestInitResponse.getDigestHandle()));
//        return digestInitResponse;
//    }
//
//    private static DigestUpdateResponse digestUpdate() throws TAException {
//        String digestHandle = digestInit().getDigestHandle();
//        String data = orgSignData;
//        DigestUpdateResponse digestUpdateResponse = signServerApi.digestUpdate(digestHandle, data);
//        System.out.println("摘要计算 更新：" + String.format(printFormat, digestUpdateResponse.getCode(), digestUpdateResponse.getMsg(), digestUpdateResponse.getDigestHandle()));
//        return digestUpdateResponse;
//    }
//
//    private static void digestFinal() throws TAException {
//        String digestHandle = digestUpdate().getDigestHandle();
//        DigestFinalResponse digestFinalResponse = signServerApi.digestFinal(digestHandle);
//        System.out.println("摘要计算 结束：" + String.format(printFormat, digestFinalResponse.getCode(), digestFinalResponse.getMsg(), digestFinalResponse.getDigest()));
//
//    }
//
//    private static void sm2ZValueInner() throws TAException {
//        String sm2KeyId = "tasstest_sm2";
//        int sm2KeyIdType = 0;
//        String sm2UserID = "";
//        SM2ZValueResponse sm2ZValueResponse = signServerApi.sm2ZValueInner(sm2KeyId, sm2KeyIdType, sm2UserID);
//        System.out.println("sm2 Z值计算（内部密钥）：" + String.format(printFormat, sm2ZValueResponse.getCode(), sm2ZValueResponse.getMsg(), sm2ZValueResponse.getzValue()));
//    }
//
//    private static void sm2ZValueExt() throws TAException {
//        String sm2PubKeyInfo = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        int sm2PubKeyInfoType = 1;
//        String sm2UserID = "";
//        SM2ZValueResponse sm2ZValueResponse = signServerApi.sm2ZValueExt(sm2PubKeyInfo, sm2PubKeyInfoType, sm2UserID);
//        System.out.println("sm2 Z值计算（内部密钥）：" + String.format(printFormat, sm2ZValueResponse.getCode(), sm2ZValueResponse.getMsg(), sm2ZValueResponse.getzValue()));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 非对称加解密
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static AsymOperationResponse asymEncryptInner() throws TAException {
//        String keyOrCertId = "tasstest_sm2";
//        int keyOrCertIdType = 0;
//        String data = orgSignData;
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymEncrypt(keyOrCertId, keyOrCertIdType, data, encFormat);
//        System.out.println("非对称加密 内部密钥：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getEncrypt()));
//        return asymOperationResponse;
//    }
//
//    private static void asymDecryptInner1() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String encrypt = asymEncryptInner().getEncrypt();
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecrypt(keyId, keyIdType, keyAccessCode, encrypt, encFormat);
//        System.out.println("非对称解密 内部密钥：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//    }
//
//    private static void asymDecryptInner2() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String encrypt = asymEncryptInner().getEncrypt();
//        int encFormat = 1;
//        String transEncKeyId = "sm4";
//        String transEncKeyAccessCode = "";
//        int transEncMode = 0;
//        int transEncPadMode = 1;
//        String transEncIv = "";
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecrypt(keyId, keyIdType, keyAccessCode, encrypt, encFormat, transEncKeyId, transEncKeyAccessCode, transEncMode, transEncPadMode, transEncIv);
//        System.out.println("非对称解密 内部密钥 结果转加密：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//
//    }
//
//    private static AsymOperationResponse asymEncryptExt() throws TAException {
//        String pubKeyInfo = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        int pubKeyInfoType = 1;
//        String data = orgSignData;
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymEncryptExternal(pubKeyInfo, pubKeyInfoType, data, encFormat);
//        System.out.println("非对称加密 外部证书：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getEncrypt()));
//        return asymOperationResponse;
//    }
//
//    private static void asymDecryptExt1() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String encrypt = asymEncryptExt().getEncrypt();
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecryptExternal(privKey, encrypt, encFormat);
//        System.out.println("非对称解密 外部明文私钥：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//
//    }
//
//    private static void asymDecryptExt2() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String encrypt = asymEncryptExt().getEncrypt();
//        int encFormat = 1;
//        String transEncKeyId = "sm4";
//        String transEncKeyAccessCode = "";
//        int transEncMode = 0;
//        int transEncPadMode = 1;
//        String transEncIv = "";
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecryptExternal(privKey, encrypt, encFormat, transEncKeyId, transEncKeyAccessCode, transEncMode, transEncPadMode, transEncIv);
//        System.out.println("非对称解密 外部明文私钥 转加密输出：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//
//    }
//
//    private static void asymDecryptExt3() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String encrypt = "MIGJAiEA1vL5i0L5eOq2G8IcG/iezsxVQXgePT8xwH5j2aQ78nACICv55OY1l3/HN8xUJUbJBMBgpryRZ5qrgqyMKm0ZkqJnBCCBNXdeWXYrbB+c07aZxCRM9asw2TE7lEJ8goAenigq2wQg8t8HXqKETgOgUE/v0wTzDMLR6gmO9sV2O4d2KkDzWQE=";
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecryptExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, encrypt, encFormat);
//        System.out.println("非对称解密 外部密文私钥 明文输出：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//    }
//
//    private static void asymDecryptExt4() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String encrypt = "MIGJAiEA1vL5i0L5eOq2G8IcG/iezsxVQXgePT8xwH5j2aQ78nACICv55OY1l3/HN8xUJUbJBMBgpryRZ5qrgqyMKm0ZkqJnBCCBNXdeWXYrbB+c07aZxCRM9asw2TE7lEJ8goAenigq2wQg8t8HXqKETgOgUE/v0wTzDMLR6gmO9sV2O4d2KkDzWQE=";
//        int encFormat = 1;
//        String transEncKeyId = "sm4";
//        String transEncKeyAccessCode = "";
//        int transEncMode = 0;
//        int transEncPadMode = 1;
//        String transEncIv = "";
//        AsymOperationResponse asymOperationResponse = signServerApi.asymDecryptExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, encrypt, encFormat, transEncKeyId, transEncKeyAccessCode, transEncMode, transEncPadMode, transEncIv);
//        System.out.println("非对称解密 外部密文私钥 转加密输出：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getData()));
//    }
//
//    /**
//     * 内部对称加密转内部非对称公钥加密
//     *
//     * @throws TAException
//     */
//    private static void asymEncryptInner1() throws TAException {
//        //1、对称密钥加密
//        String keyId = "sm4";
//        String keyAccessCode = "";
//        int mode = 1;
//        int padMode = 1;
//        String iv = Base64.toBase64String("1111111111111111".getBytes());
//        String data = orgSignData;
//        SymOperationResponse symOperationResponse = signServerApi.symEncrypt(keyId, keyAccessCode, mode, padMode, iv, data);
//        System.out.println("对称加密 - 内部密钥： " + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//        //2、非对称密钥加密第一步中加密的密文----转加密，将对称密钥加密的数据转为非对称密钥加密
//        String keyOrCertId = "tasstest_sm2";
//        int keyOrCertIdType = 0;
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymEncrypt(keyOrCertId, keyOrCertIdType, symOperationResponse.getResult(), encFormat, keyId, keyAccessCode, mode, padMode, iv);
//        System.out.println("非对称加密 内部密钥：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getEncrypt()));
//    }
//
//    /**
//     * 内部对称加密转外部非对称公钥加密
//     *
//     * @throws TAException
//     */
//    private static void asymEncryptExt1() throws TAException {
//        //1、对称密钥加密
//        String keyId = "sm4";
//        String keyAccessCode = "";
//        int mode = 1;
//        int padMode = 1;
//        String iv = Base64.toBase64String("1111111111111111".getBytes());
//        String data = orgSignData;
//        SymOperationResponse symOperationResponse = signServerApi.symEncrypt(keyId, keyAccessCode, mode, padMode, iv, data);
//        System.out.println("对称加密 - 内部密钥： " + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//        //2、非对称密钥加密第一步中加密的密文----转加密，将对称密钥加密的数据转为非对称密钥加密
//        String pubKeyInfo = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        int pubKeyInfoType = 1;
//        int encFormat = 1;
//        AsymOperationResponse asymOperationResponse = signServerApi.asymEncryptExternal(pubKeyInfo, pubKeyInfoType, symOperationResponse.getResult(), encFormat, keyId, keyAccessCode, mode, padMode, iv);
//        System.out.println("非对称加密 外部证书：" + String.format(printFormat, asymOperationResponse.getCode(), asymOperationResponse.getMsg(), asymOperationResponse.getEncrypt()));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 对称加解密
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static SymOperationResponse symEncrpytInner() throws TAException {
//        String keyId = "sm1";
//        String keyAccessCode = "";
//        int mode = 1;
//        int padMode = 1;
//        String iv = Base64.toBase64String("1111111111111111".getBytes());
//        String data = orgSignData;
//
//        SymOperationResponse symOperationResponse = signServerApi.symEncrypt(keyId, keyAccessCode, mode, padMode, iv, data);
//        System.out.println("对称加密 - 内部密钥： " + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//        return symOperationResponse;
//    }
//
//    private static SymOperationResponse symEncrpytExt() throws TAException {
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = "SM4";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        String data = orgSignData;
//        SymOperationResponse symOperationResponse = signServerApi.symEncrypt(extKeyInfo, extKeyInfoAlg, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, mode, padMode, iv, data);
//        System.out.println("对称加密 - 外部密钥密文：" + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//        return symOperationResponse;
//    }
//
//    private static SymOperationResponse symDecryptInner() throws TAException {
//        String keyId = "sm1";
//        String keyAccessCode = "";
//        int mode = 1;
//        int padMode = 1;
//        String iv = "MTExMTExMTExMTExMTExMQ==";
//        String data = "iod+68fdaMHhJ++wD1ikwGDp/tXh64amzXesuQQoXNUusshFXFj49hp5eQBOdVWc"; //symEncrpytInner().getResult();
//        SymOperationResponse symOperationResponse = signServerApi.symDecrypt(keyId, keyAccessCode, mode, padMode, iv, data);
//        System.out.println("对称解密 - 内部密钥解密：" + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//
//        return symOperationResponse;
//    }
//
//    private static void symDecryptExt() throws TAException {
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = "SM4";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        String data = symEncrpytExt().getResult();
//        SymOperationResponse symOperationResponse = signServerApi.symDecrypt(extKeyInfo, extKeyInfoAlg, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, mode, padMode, iv, data);
//        System.out.println("对称解密 - 外部密钥密文：" + String.format(printFormat, symOperationResponse.getCode(), symOperationResponse.getMsg(), symOperationResponse.getResult()));
//
//    }
//
//    private static SymOperationMultiInitResponse symEncryptInitInner() throws TAException {
//        String keyId = "sm4";
//        String keyAccessCode = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        SymOperationMultiInitResponse symOperationMultiInitResponse = signServerApi.symEncryptMultiInit(keyId, keyAccessCode, mode, padMode, iv);
//        System.out.println("对称加密 - 多包初始化 - 内部密钥" + String.format(printFormat, symOperationMultiInitResponse.getCode(), symOperationMultiInitResponse.getMsg(), symOperationMultiInitResponse.getSymHandle()));
//        return symOperationMultiInitResponse;
//    }
//
//    private static SymOperationMultiInitResponse symEncryptInitExt() throws TAException {
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = "SM4";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        SymOperationMultiInitResponse symOperationMultiInitResponse = signServerApi.symEncryptMultiInit(extKeyInfo, extKeyInfoAlg, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, mode, padMode, iv);
//        System.out.println("对称加密 - 多包初始化 - 外部密钥" + String.format(printFormat, symOperationMultiInitResponse.getCode(), symOperationMultiInitResponse.getMsg(), symOperationMultiInitResponse.getSymHandle()));
//        return symOperationMultiInitResponse;
//    }
//
//    private static SymOperationMultiUpdateResponse symEncryptUpdate() throws TAException {
//        String symHandle = symEncryptInitInner().getSymHandle();
//        String data = orgSignData;
//        SymOperationMultiUpdateResponse symOperationMultiUpdateResponse = signServerApi.symEncryptMultiUpdate(symHandle, data);
//        System.out.println("对称加密 - 多包更新" + String.format(printFormat, symOperationMultiUpdateResponse.getCode(), symOperationMultiUpdateResponse.getMsg(), symOperationMultiUpdateResponse.toString()));
//
//        return symOperationMultiUpdateResponse;
//    }
//
//    private static SymOperationMultiFinalResponse symEncryptFinal() throws TAException {
//        String symHandle = symEncryptUpdate().getSymHandle();
//        SymOperationMultiFinalResponse symOperationMultiFinalResponse = signServerApi.symEncryptMultiFinal(symHandle);
//        System.out.println("对称加密 - 多包结束" + String.format(printFormat, symOperationMultiFinalResponse.getCode(), symOperationMultiFinalResponse.getMsg(), symOperationMultiFinalResponse.getResult()));
//
//        return symOperationMultiFinalResponse;
//    }
//
//    private static SymOperationMultiInitResponse symDecryptInitInner() throws TAException {
//        String keyId = "sm4";
//        String keyAccessCode = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        SymOperationMultiInitResponse symOperationMultiInitResponse = signServerApi.symDecryptMultiInit(keyId, keyAccessCode, mode, padMode, iv);
//        System.out.println("对称解密 - 多包初始 - 内部密钥" + String.format(printFormat, symOperationMultiInitResponse.getCode(), symOperationMultiInitResponse.getMsg(), symOperationMultiInitResponse.getSymHandle()));
//
//        return symOperationMultiInitResponse;
//    }
//
//    private static SymOperationMultiInitResponse symDecryptInitExt() throws TAException {
//        String extKeyInfo = "6+Yj0P7gMTM/Dy/hZZVqt/ha+7LDkk0TL/2ecJEyUcs=";
//        String extKeyInfoAlg = "SM4";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        int mode = 0;
//        int padMode = 1;
//        String iv = "";
//        SymOperationMultiInitResponse symOperationMultiInitResponse = signServerApi.symDecryptMultiInit(extKeyInfo, extKeyInfoAlg, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, mode, padMode, iv);
//        System.out.println("对称解密 - 多包初始 - 外部密钥" + String.format(printFormat, symOperationMultiInitResponse.getCode(), symOperationMultiInitResponse.getMsg(), symOperationMultiInitResponse.getSymHandle()));
//        return symOperationMultiInitResponse;
//    }
//
//    /**
//     * 注意： 解密数据，是多包更新的result拼接上多包结束的result
//     *
//     * @return
//     * @throws TAException
//     */
//    private static SymOperationMultiUpdateResponse symDecryptUpdate() throws TAException {
//        String symHandle = symDecryptInitInner().getSymHandle();
//        String update = symEncryptUpdate().getResult();
//        String finalData = symEncryptFinal().getResult();
//
//        byte[] decode1 = Base64.decode(update);
//
//        byte[] decode2 = Base64.decode(finalData);
//
//        byte[] newData = new byte[decode1.length + decode2.length];
//
//        System.arraycopy(decode1, 0, newData, 0, decode1.length);
//        System.arraycopy(decode2, 0, newData, decode1.length, decode2.length);
//
//        String data = Base64.toBase64String(newData);
//
//        SymOperationMultiUpdateResponse symOperationMultiUpdateResponse = signServerApi.symDecryptMultiUpdate(symHandle, data);
//        System.out.println("对称解密 - 多包更新" + String.format(printFormat, symOperationMultiUpdateResponse.getCode(), symOperationMultiUpdateResponse.getMsg(), symOperationMultiUpdateResponse.toString()));
//
//        return symOperationMultiUpdateResponse;
//    }
//
//    private static void symDecryptFinal() throws TAException {
//        String symHandle = symDecryptUpdate().getSymHandle();
//        SymOperationMultiFinalResponse symOperationMultiFinalResponse = signServerApi.symDecryptMultiFinal(symHandle);
//        System.out.println("对称解密 - 多包结束" + String.format(printFormat, symOperationMultiFinalResponse.getCode(), symOperationMultiFinalResponse.getMsg(), symOperationMultiFinalResponse.getResult()));
//    }
//
//
//    ///////////////////////////////////////////////////////////////////////////
//    // p7数字信封
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static P7EnvelopResponse p7EnvelopInnerKey() throws TAException {
//        String keyOrCertId = "tasstest_sm2";
//        int keyOrCertIdType = 0;
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        boolean checkCert = false;
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        P7EnvelopResponse p7EnvelopResponse = signServerApi.p7Envelop(keyOrCertId, keyOrCertIdType, encAlgorithm, data, checkCert, isReturnCertInfo, infoType);
//        System.out.println("制作p7数字信封：" + String.format(printFormat, p7EnvelopResponse.getCode(), p7EnvelopResponse.getMsg(), p7EnvelopResponse.toString()));
//        return p7EnvelopResponse;
//    }
//
//    private static void decryptEnvelopInnerKey() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        String envelop = p7EnvelopInnerKey().getEnvelop();
//        DecryptP7EnvelopResponse decryptP7EnvelopResponse = signServerApi.decryptP7Envelop(keyId, keyIdType, keyAccessCode, envelop, isReturnCertInfo, infoType);
//        System.out.println("解密p7数字信封：" + String.format(printFormat, decryptP7EnvelopResponse.getCode(), decryptP7EnvelopResponse.getMsg(), decryptP7EnvelopResponse.toString()));
//    }
//
//    private static P7EnvelopExternalResponse p7EnvelopExter() throws TAException {
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        P7EnvelopExternalResponse p7EnvelopExternalResponse = signServerApi.p7EnvelopExternal(cert, encAlgorithm, data, isReturnCertInfo, infoType);
//        System.out.println("外部证书制作p7信封：" + String.format(printFormat, p7EnvelopExternalResponse.getCode(), p7EnvelopExternalResponse.getMsg(), p7EnvelopExternalResponse.toString()));
//        return p7EnvelopExternalResponse;
//    }
//
//    private static void decryptEnvelopExter() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String envelop = p7EnvelopExter().getEnvelop();
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        DecryptP7EnvelopExternalResponse decryptP7EnvelopExternalResponse = signServerApi.decryptP7EnvelopExternal(privKey, cert, envelop, isReturnCertInfo, infoType);
//        System.out.println("外部证书(私钥明文)解密p7信封：" + String.format(printFormat, decryptP7EnvelopExternalResponse.getCode(), decryptP7EnvelopExternalResponse.getMsg(), decryptP7EnvelopExternalResponse.toString()));
//    }
//
//    private static void decryptEnvelopExterCipher() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String cert = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        String envelop = "MIIBHAYKKoEcz1UGAQQCA6CCAQwwggEIAgEAMYG3MIG0AgEAMCUwGzEZMBcGA1UEAwwQdGFzc3Rlc3Rfc20ycm9vdAIGAWxCfKQ6MAsGCSqBHM9VAYItAwR7MHkCIFQ0xVMhF8zIcOuu8J8mXtvdkwuvQ/aHsSDUvSCBgye9AiEA2hwZcJjgNeKF8mI1FFgzwUF5SIf/8jVGKJjeSEGR+roEIO/xv7YiURmzLfIn6ARRJ2vIektCqjREmAxVC2t93+N3BBDTp/8fvlfSu5QXVA+hzEVzMEkGCiqBHM9VBgEEAgEwCQYHKoEcz1UBaIAwd7O8IwfxWXzjQtZ8z5FWYHezvCMH8Vl840LWfM+RVmDy6EY5UvdWtZq9Ydt0NVZh";
//        DecryptP7EnvelopExternalResponse decryptP7EnvelopExternalResponse = signServerApi.decryptP7EnvelopExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, cert, envelop, isReturnCertInfo, infoType);
//        System.out.println("外部证书(私钥密文)解密p7信封：" + String.format(printFormat, decryptP7EnvelopExternalResponse.getCode(), decryptP7EnvelopExternalResponse.getMsg(), decryptP7EnvelopExternalResponse.toString()));
//    }
//
//
//    private static P7SignedAndEnvelopResponse p7EnvelopWithSign1() throws TAException {
//        String signKeyId = "tasstest_sm2";
//        int signKeyIdType = 0;
//        String signKeyAccessCode = "";
//
//        String signAlgorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String encKeyOrCertId = "tasstest_sm2";
//        int encKeyOrCertIdType = 0;
//
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        String sm2UserID = "";
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        P7SignedAndEnvelopResponse p7SignedAndEnvelopResponse = signServerApi.p7CreateSignedAndEnvelop(signKeyId, signKeyIdType, signKeyAccessCode, signAlgorithm, encKeyOrCertId, encKeyOrCertIdType,
//                encAlgorithm, data, sm2UserID, isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("编制p7带签名的数字证书 -（签名使用内部密钥，加密使用内部密钥）：" + String.format(printFormat, p7SignedAndEnvelopResponse.getCode(), p7SignedAndEnvelopResponse.getMsg(), p7SignedAndEnvelopResponse.toString()));
//        return p7SignedAndEnvelopResponse;
//    }
//
//    private static P7SignedAndEnvelopResponse p7EnvelopWithSign2() throws TAException {
//        String signAlgorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String signPrivKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String signCert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String encKeyId = "";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 0;
//        String encIv = "";
//        String encKeyOrCertId = "tasstest_sm2";
//        int encKeyOrCertIdType = 0;
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        String sm2UserID = "";
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        P7SignedAndEnvelopResponse p7SignedAndEnvelopResponse = signServerApi.p7CreateSignedAndEnvelop(signAlgorithm, signPrivKey, signCert, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv,
//                encKeyOrCertId, encKeyOrCertIdType, encAlgorithm, data, sm2UserID, isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("编制p7带签名的数字证书 - 外部密钥加签，加密使用内部密钥：" + String.format(printFormat, p7SignedAndEnvelopResponse.getCode(), p7SignedAndEnvelopResponse.getMsg(), p7SignedAndEnvelopResponse.toString()));
//        return p7SignedAndEnvelopResponse;
//    }
//
//    private static P7SignedAndEnvelopResponse p7EnvelopWithSign3() throws TAException {
//        String signAlgorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String signPrivKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String signCert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String encKeyId = "";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 0;
//        String encIv = "";
//        String encCert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        String sm2UserID = "";
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        P7SignedAndEnvelopResponse p7SignedAndEnvelopResponse = signServerApi.p7CreateSignedAndEnvelop(signAlgorithm, signPrivKey, signCert, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv,
//                encCert, encAlgorithm, data, sm2UserID, isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("编制p7带签名的数字证书 - 外部密钥加签，加密使用外部证书：" + String.format(printFormat, p7SignedAndEnvelopResponse.getCode(), p7SignedAndEnvelopResponse.getMsg(), p7SignedAndEnvelopResponse.toString()));
//        return p7SignedAndEnvelopResponse;
//    }
//
//    private static P7SignedAndEnvelopResponse p7EnvelopWithSign4() throws TAException {
//        String signKeyId = "tasstest_sm2";
//        int signKeyIdType = 0;
//        String signKeyAccessCode = "";
//        String signAlgorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        String sm2UserID = "";
//        String encCert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        P7SignedAndEnvelopResponse p7SignedAndEnvelopResponse = signServerApi.p7CreateSignedAndEnvelop(signKeyId, signKeyIdType, signKeyAccessCode, signAlgorithm, encCert, encAlgorithm, data, sm2UserID,
//                isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("编制p7带签名的数字证书 - 签名使用内部密钥，加密使用外部证书：" + String.format(printFormat, p7SignedAndEnvelopResponse.getCode(), p7SignedAndEnvelopResponse.getMsg(), p7SignedAndEnvelopResponse.toString()));
//        return p7SignedAndEnvelopResponse;
//    }
//
//    private static void decryptEnvelopWithSignInner() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String envelop = p7EnvelopWithSign1().getEnvelop();
//        String sm2UserID = "";
//        int verifyLevel = 0;
//        boolean isReturnCert = true;
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 0;
//        DecryptP7SignedAndEnvelopResponse decryptP7SignedAndEnvelopResponse = signServerApi.decryptP7SignedAndEnvelop(keyId, keyIdType, keyAccessCode, envelop, sm2UserID, verifyLevel, isReturnCert,
//                isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("解密P7带签名数字信封 - 内部非对称解密：" + String.format(printFormat, decryptP7SignedAndEnvelopResponse.getCode(), decryptP7SignedAndEnvelopResponse.getMsg(), decryptP7SignedAndEnvelopResponse.toString()));
//    }
//
//    private static void decryptEnvelopWithSignExter() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String encKeyId = "";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 0;
//        String encIv = "";
//        String envelop = p7EnvelopWithSign4().getEnvelop();
//        String sm2UserID = "";
//        int verifyLevel = 0;
//        boolean isReturnCert = true;
//        boolean isAttachSign = true;
//        int attachSignFormat = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        DecryptP7SignedAndEnvelopResponse decryptP7SignedAndEnvelopResponse = signServerApi.decryptP7SignedAndEnvelop(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, envelop, sm2UserID,
//                verifyLevel, isReturnCert, isAttachSign, attachSignFormat, isReturnCertInfo, infoType);
//        System.out.println("解密P7带签名数字信封 - 外部私钥明文：" + String.format(printFormat, decryptP7SignedAndEnvelopResponse.getCode(), decryptP7SignedAndEnvelopResponse.getMsg(), decryptP7SignedAndEnvelopResponse.toString()));
//    }
//
//    /**
//     * 扩展解密p7数字信封--加密使用p7Envelop
//     * 且需要将证书导入加密机
//     */
//    private static void decryptP7EnvelopByCert() throws TAException {
//        //证书信息
//        String cert = "MIIDhTCCAm+gAwIBAgIGAWxCgHe3MAsGCSqGSIb3DQEBCzAfMR0wGwYDVQQDDBR0\n" +
//                "YXNzdGVzdF9yc2Fyb290MjA0ODAiGA8yMDE5MDczMDEwNTAxMVoYDzIwMjkwNzMw\n" +
//                "MTA1MDExWjAbMRkwFwYDVQQDDBB0YXNzdGVzdF9yc2EyMDQ4MIIBIjANBgkqhkiG\n" +
//                "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhoV9wsOpMnN5NZSIfOw1OU/novGIX0XZPhcK\n" +
//                "dMtiMaHyKOMdDlPg1JDyp/qIqMSxs9so51AZGmS0HVsV9DySbPT6HQZ0nMvD/Lpw\n" +
//                "w7s1d/5asoRXFsRZxBKhVeeCGnf5rvo6LAhkGDwD+ax+FIy+U5P5Aqr5235dneGo\n" +
//                "/dF3HkBaxKsXFTGAgF40hf1tmaLG6SdkCx77KBwnPqVa8g8azG2kLp6JfSDf7AGX\n" +
//                "DPsdwPG6+r3xA86PcMA63YbRy/R/4j1IjOxA1JLjaiJ3KRUgy8ZjMy32PJFvY6QV\n" +
//                "HkOzn3ZUlpqOk6x7WkSkQFp1BJQ3m/6GgYCbJG1qP9ykpGoPjwIDAQABgRgAQ049\n" +
//                "dGFzc3Rlc3RfcnNhcm9vdDIwNDiCFABDTj10YXNzdGVzdF9yc2EyMDQ4o4GaMIGX\n" +
//                "MAwGA1UdDwQFAwMA/4AwHwYDVR0jBBgwFoAU2/YFbso/2gBdrTAxWF26lV/RBoQw\n" +
//                "HQYDVR0OBBYEFNhqeMigB6gDrrJm+tDkxkjNhL14MEcGA1UdJQRAMD4GCCsGAQUF\n" +
//                "BwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggr\n" +
//                "BgEFBQcDAjALBgkqhkiG9w0BAQsDggEBAMAWKYXZ5Msp7qmHesZfsA4ypu2hKkmh\n" +
//                "rVMmczXVI2hFcb+gogdmb2Zbg0wRRldgZnQ+smMdKXc+CRUoCbmteE0wuTK3opEE\n" +
//                "EEBxXpDByEx+zAd7IFkO9XfXVlLv6eZ85brfdYN6NOxd/VdopSR+KtzdAGfuFHtG\n" +
//                "jTGKZzPclwKX1ahfvOZBG/A9YM4SpbMAcPZ+mQ0GqPaC3liiZ6IZdCmyThFQLW2H\n" +
//                "BUaScZzrrffpQfORmRjtlXl5f6ymhDitpgYilBzhPUO7R/LuFg3/zGjUfX3woLEc\n" +
//                "o3U4PGyQL/QrHzmW6Qn8fV5HWV4BgAPrRAeW704sTQlHvRH40PrP58I=";
//        int infoType = 0;
//        int keyOrCertIdType = 2;
//        String encAlgorithm = TACryptConst.GBSMS4_CBC;
//        String data = orgSignData;
//        boolean checkCert = false;
//        boolean isReturnCertInfo = true;
//        P7EnvelopResponse response = signServerApi.p7Envelop("tasstest_rsa2048_cert", keyOrCertIdType, encAlgorithm, data, checkCert, isReturnCertInfo, infoType);
//        System.out.println("制作p7数字信封：" + String.format(printFormat, response.getCode(), response.getMsg(), response.toString()));
//        DecryptP7EnvelopResponse decryptP7EnvelopResponse = signServerApi.decryptP7EnvelopByCert(cert, response.getEnvelop(), isReturnCertInfo, infoType);
//        System.out.println("解密P7数字信封（外部证书）：" + String.format(printFormat, decryptP7EnvelopResponse.getCode(), decryptP7EnvelopResponse.getMsg(), decryptP7EnvelopResponse.toString()));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 裸签名
//    ///////////////////////////////////////////////////////////////////////////
//    private static String orgSignData = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ1Njc4MTIzNDU2Nzg=";
//
//    private static RawSignResponse innerKeyRawSign() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String data = orgSignData;
//        int dataType = 0;   // 数据类型可以改为1
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        RawSignResponse rawSignResponse = signServerApi.rawSign(keyId, keyIdType, keyAccessCode, data, dataType, isReturnCertInfo, infoType);
//        if (0 != rawSignResponse.getCode()) {
//            System.err.println("裸签名失败：" + rawSignResponse.getMsg());
//        } else {
//            System.out.println("裸签名结果：[" + rawSignResponse.toString() + "]");
//        }
//        return rawSignResponse;
//    }
//
//    private static RawSignResponse innerKeyRawSignWholeParam() throws TAException {
//        String keyId = "tasstest_sm2";
//        int keyIdType = 0;
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String sm2UserID = "";
//        int rsaPadMode = 0;
//        boolean checkCert = true;
//        int signFormat = 1;
//        String keyAccessCode = "";
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        RawSignResponse rawSignResponse = signServerApi.rawSign(keyId, keyIdType, algorithm, sm2UserID, rsaPadMode, checkCert, signFormat, keyAccessCode, data, dataType, isReturnCertInfo, infoType);
//        if (0 != rawSignResponse.getCode()) {
//            System.err.println("裸签名失败：" + rawSignResponse.getMsg());
//        } else {
//            System.out.println("裸签名结果：[" + rawSignResponse.toString() + "]");
//        }
//        return rawSignResponse;
//    }
//
//    private static void verifyRawSign() throws TAException {
//        String sign = innerKeyRawSign().getSign();
//        String keyOrCertId = "tasstest_sm2";
//        int keyOrCertIdType = 0;
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyRawSignResponse verifyRawSignResponse = signServerApi.verifyRawSign(keyOrCertId, keyOrCertIdType, data, dataType, sign, isReturnCertInfo, infoType);
//        if (0 != verifyRawSignResponse.getCode()) {
//            System.err.println("验签失败：" + verifyRawSignResponse.toString());
//        } else {
//            System.out.println("验签成功");
//        }
//    }
//
//    private static void verifyRawSignWholeParam() throws TAException {
//        String keyOrCertId = "tasstest_sm2";
//        int keyOrCertIdType = 0;
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        String sign = innerKeyRawSignWholeParam().getSign();
//        int signFormat = 1;
//        String sm2UserID = "";
//        int rsaPadMode = 0;
//        int verifyLevel = 3;
//        boolean isReturnPubKeyInfo = true;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyRawSignResponse verifyRawSignResponse = signServerApi.verifyRawSign(keyOrCertId, keyOrCertIdType, algorithm, data, dataType, sign, signFormat, sm2UserID, rsaPadMode, verifyLevel,
//                isReturnPubKeyInfo, isReturnCertInfo, infoType);
//        System.out.println("验签结果：" + String.format(printFormat, verifyRawSignResponse.getCode(), verifyRawSignResponse.getMsg(), verifyRawSignResponse.toString()));
//    }
//
//    private static RawSignExternalResponse exterKeyRawSign() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String data = orgSignData;
//        int dataType = 0;
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String sm2UserId = "";
//        String sm2PubkeyInfo = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7g==";
//        int sm2PubkeyInfoType = 0;
//        int rsaPadMode = 0;
//        int signFormat = 1;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        RawSignExternalResponse rawSignExternalResponse = signServerApi.rawSignExternal(privKey, data, dataType, algorithm, sm2UserId, sm2PubkeyInfo, sm2PubkeyInfoType, rsaPadMode, signFormat, isReturnCertInfo, infoType);
//        System.out.println("外部私钥明文签名结果：" + String.format(printFormat, rawSignExternalResponse.getCode(), rawSignExternalResponse.getMsg(), rawSignExternalResponse.toString()));
//        return rawSignExternalResponse;
//    }
//
//    private static void exterCipherKeyRawSign() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        //"GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo9fPsTMAHbSeB1cAJ1xVkXAmJe/Fp99Qr1Xiqpm3pVEXiQsENdHLcxzkLLMygoshus=";
//        String encKeyId = "sm1";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 1;
//        String encIv = "";
//        String data = orgSignData;
//        int dataType = 0;
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String sm2UserId = "";
//        String sm2PubkeyInfo = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7g==";
//        int sm2PubkeyInfoType = 0;
//        int rsaPadMode = 0;
//        int signFormat = 1;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        RawSignExternalResponse rawSignExternalResponse = signServerApi.rawSignExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, data, dataType, algorithm, sm2UserId, sm2PubkeyInfo, sm2PubkeyInfoType, rsaPadMode, signFormat, isReturnCertInfo, infoType);
//        System.out.println("外部私钥密文签名结果：" + String.format(printFormat, rawSignExternalResponse.getCode(), rawSignExternalResponse.getMsg(), rawSignExternalResponse.toString()));
//    }
//
//    private static void exterKeyVerifySign() throws TAException {
//        String pubKeyInfo = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7g==";
//
//        int pubKeyInfoType = 0;
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        String sign = exterKeyRawSign().getSign();
//
//        int signFormat = 1;
//        String sm2UserID = "";
//        int rsaPadMode = 0;
//        int verifyLevel = 0;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyRawsignExternalResponse verifyRawsignExternalResponse = signServerApi.verifyRawsignExternal(pubKeyInfo, pubKeyInfoType, algorithm, data, dataType, sign, signFormat, sm2UserID, rsaPadMode, verifyLevel, isReturnCertInfo, infoType);
//        System.out.println("外部公钥验签：" + String.format(printFormat, verifyRawsignExternalResponse.getCode(), verifyRawsignExternalResponse.getMsg(), verifyRawsignExternalResponse.toString()));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // p7签名
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static P7SignResponse p7SignInnerKey() throws TAException {
//        String keyId = "enckeyimptest";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isDetach = true;
//        String sm2UserID = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        int signCertType = 0;
//        P7SignResponse p7SignResponse = signServerApi.p7Sign(keyId, keyIdType, keyAccessCode, sm2UserID, algorithm, data, dataType, isDetach, isReturnCertInfo, infoType, signCertType);
//        System.out.println("p7签名(内部密钥)：" + String.format(printFormat, p7SignResponse.getCode(), p7SignResponse.getMsg(), p7SignResponse.toString()));
//        return p7SignResponse;
//    }
//
//    private static P7SignResponse p7SignExtInnerKey() throws TAException {
//        String keyId = "enckeyimptest";
//        int keyIdType = 0;
//        String keyAccessCode = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isDetach = false;
//        String sm2UserID = "";
//        boolean checkCert = true;
//        boolean isIncludeRootCert = false;
//        boolean isIncludeAuthAttr = false;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        int signCertType = 0;
//        P7SignResponse p7SignResponse = signServerApi.p7Sign(keyId, keyIdType, keyAccessCode, sm2UserID, algorithm, data, dataType,
//                checkCert, isDetach, isIncludeRootCert, isIncludeAuthAttr, null, null, isReturnCertInfo, infoType, signCertType);
//        System.out.println("扩展p7签名(内部密钥)：" + String.format(printFormat, p7SignResponse.getCode(), p7SignResponse.getMsg(), p7SignResponse.toString()));
//        return p7SignResponse;
//    }
//
//    private static void p7SignExterkey() throws TAException {
//        String privKey = "MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCBkFjAs3ErjlQFmEUcLNKqps/5yJVEs18FpuXagt+dZmg==";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isDetach = true;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        boolean isIncludeAuthAttr = false;
//        List<P7Attribute> authAttrList = null;
//        List<P7Attribute> noAuthAttrList = null;
//        String sm2UserID = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        P7SignExternalResponse p7SignExternalResponse = signServerApi.p7SignExternal(privKey, algorithm, data, dataType, isDetach, cert, sm2UserID, isIncludeAuthAttr, authAttrList, noAuthAttrList, isReturnCertInfo, infoType);
//        System.out.println("p7签名（外部密钥明文）：" + String.format(printFormat, p7SignExternalResponse.getCode(), p7SignExternalResponse.getMsg(), p7SignExternalResponse.toString()));
//
//    }
//
//    private static void p7SignExterCipherKey() throws TAException {
//        String privKey = "WHF5jHiB9+XR6pNzSOqVq1ivuIERNpxavn/RGljp24vjIsn/kbnRus9pEk7RI1Lg6TpdY+itNUCkCr9mv4yH+53PPsNpBLp/PGv36VnWFBU=";
//        //WHF5jHiB9+XR6pNzSOqVq1ivuIERNpxavn/RGljp24vjIsn/kbnRus9pEk7RI1Lg6TpdY+itNUCkCr9mv4yH+53PPsNpBLp/PGv36VnWFBU=
//        //MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCACkn79H0eu1Y95GZlYo3jC/oetUMPBhak/lJJJ62xKsA==
//        String encKeyId = "sm4";
//        String enckeyAccessCode = "";
//        int encMode = 0;
//        int encPadMode = 0;
//        String encIv = "";
//        String algorithm = TACryptConst.TA_S_ALG_SM3WITHSM2;
//        String data = orgSignData;
//        int dataType = 0;
//        boolean isDetach = true;
//        String cert = "MIIB7TCCAZOgAwIBAgIGAWxCfKQ6MAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTA3MzAxMDQ2MDBaGA8yMDI5MDczMDEwNDYwMFowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAESX5N4QuKHF4ZhBbVJ5mUexFWlZFGoAXF7e1WaeCTUOgrbWoWn2kTJnWi53KV1zzVyycZ9OpEtsduleA8mBDY7oEUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBT/6fBKQnbsVADuSooS8MUUoXIXJTAdBgNVHQ4EFgQUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0gAMEUCIQDeMX7hfHBNXwz0wbEH920YcymMNfKfdKuU+6zaRXwYuwIgMZV3aYdS0E770xMyTdNak4DkMc/sBemlVfY9QR9/5+s=";
//        boolean isIncludeAuthAttr = false;
//        List<P7Attribute> authAttrList = null;
//        List<P7Attribute> noAuthAttrList = null;
//        String sm2UserId = "";
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        P7SignExternalResponse p7SignExternalResponse = signServerApi.p7SignExternal(privKey, encKeyId, enckeyAccessCode, encMode, encPadMode, encIv, algorithm, data, dataType, isDetach, sm2UserId, cert, isIncludeAuthAttr, authAttrList, noAuthAttrList, isReturnCertInfo, infoType);
//        System.out.println("p7签名（外部密钥密文）：" + String.format(printFormat, p7SignExternalResponse.getCode(), p7SignExternalResponse.getMsg(), p7SignExternalResponse.toString()));
//
//    }
//
//    private static void verifyP7Sign() throws TAException {
//        String data = orgSignData;
//        int dataType = 0;
//        String sign = p7SignInnerKey().getSign();
//        boolean isDetach = true;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyP7SignResponse verifyP7SignResponse = signServerApi.verifyP7Sign(data, dataType, sign, isDetach, isReturnCertInfo, infoType);
//        System.out.println("验证p7签名：" + String.format(printFormat, verifyP7SignResponse.getCode(), verifyP7SignResponse.getMsg(), verifyP7SignResponse.toString()));
//    }
//
//    private static void verifyP7Sign2() throws TAException {
//        String data = orgSignData;
//        int dataType = 0;
//        String sign = p7SignInnerKey().getSign();
//        boolean isDetach = true;
//        String sm2UserID = "";
//        int verifyLevel = 0;
//        boolean isReturnCert = true;
//        boolean isReturnData = false;
//        boolean isReturnCertInfo = true;
//        int infoType = 1;
//        VerifyP7SignResponse verifyP7SignResponse = signServerApi.verifyP7Sign(data, dataType, sign, isDetach, sm2UserID, verifyLevel, isReturnCert, isReturnData, isReturnCertInfo, infoType);
//        System.out.println("验证p7签名：" + String.format(printFormat, verifyP7SignResponse.getCode(), verifyP7SignResponse.getMsg(), verifyP7SignResponse.toString()));
//    }
//
//    private static void getP7SignInfo() throws TAException {
//        String sign = p7SignInnerKey().getSign();
//        int infoType = 0;
//        GetInfoFromP7SignResponse infoFromP7Sign = signServerApi.getInfoFromP7Sign(sign, infoType);
//        System.out.println("获取p7签名信息：" + String.format(printFormat, infoFromP7Sign.getCode(), infoFromP7Sign.getMsg(), infoFromP7Sign.toString()));
//    }
//
//    // 补充的测试用例
//
//    // 测试多包解密，拆分加密结果为2份，调用两次update，测试结果
//
//    private static void mutipleDecryptTest() throws TAException {
//        String cipher = symEncrpytInner().getResult();//"LYlxWzisjrdA8FzJeKgQdC2JcVs4rI63QPBcyXioEHSC+KgEWmGJn7jGJpTTA0hj";
//        // 为实际多包加密的结果
//        byte[] newData = Base64.decode(cipher);
//        System.err.println("newData长度：" + newData.length);
//
//        // 拆包
//        byte[] cipher1 = new byte[24];
//        byte[] cipher2 = new byte[24];
//        System.arraycopy(newData, 0, cipher1, 0, cipher1.length);
//        System.arraycopy(newData, cipher1.length, cipher2, 0, cipher2.length);
//        System.err.println(Arrays.toString(newData));
//        System.err.println(Arrays.toString(cipher1));
//        System.err.println(Arrays.toString(cipher2));
//        System.err.println("长度是否一致： " + ((cipher1.length + cipher2.length) == newData.length));
//
//        // 调用一次解密
//        String symHandle = symDecryptInitInner().getSymHandle();
//        SymOperationMultiUpdateResponse symOperationMultiUpdateResponse = signServerApi.symDecryptMultiUpdate(symHandle, Base64.toBase64String(cipher1));
//        System.err.println("第一次update的结果： " + symOperationMultiUpdateResponse.toString());
//        // 再调用一次解密
//        SymOperationMultiUpdateResponse symOperationMultiUpdateResponse1 = signServerApi.symDecryptMultiUpdate(symOperationMultiUpdateResponse.getSymHandle(), Base64.toBase64String(cipher2));
//        System.err.println("第二次update的结果： " + symOperationMultiUpdateResponse1.toString());
//
//        // 输出两次解密的结果拼集
//        String d1 = symOperationMultiUpdateResponse.getResult();
//        String d2 = symOperationMultiUpdateResponse1.getResult();
//        byte[] bd1 = Base64.decode(d1);
//        byte[] bd2 = Base64.decode(d2);
//        byte[] newD = new byte[bd1.length + bd2.length];
//        System.arraycopy(bd1, 0, newD, 0, bd1.length);
//        System.arraycopy(bd2, 0, newD, bd1.length, bd2.length);
//        System.err.println("两次解密结果的拼集：" + Base64.toBase64String(newD));
//
//        // 再调用一次多包解密结束
//        SymOperationMultiFinalResponse symOperationMultiFinalResponse = signServerApi.symDecryptMultiFinal(symOperationMultiUpdateResponse1.getSymHandle());
//        System.err.println("调用多包结束结果： " + symOperationMultiFinalResponse.getResult());
//        // 如果结果不是空，需要再拼接前两次的结果
//        if (!StringUtils.isEmpty(symOperationMultiFinalResponse.getResult())) {
//            String finalResult = symOperationMultiFinalResponse.getResult();
//            byte[] f = Base64.decode(finalResult);
//            byte[] fi = new byte[f.length + newD.length];
//            System.arraycopy(newD, 0, fi, 0, newD.length);
//            System.arraycopy(f, newD.length, fi, 0, f.length);
//            System.err.println("最终解密结果： " + Base64.toBase64String(fi));
//        }
//
//    }
//    ///////////////////////////////////////////////////////////////////////////
//    // 电子印章相关指令签名
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static String makeSeal() throws TAException {
//        byte[] sealPic = FileUtils.getBytesByFile("./test.jpg");
//        String sealCert1 = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        String sealCert2 = "MIIB7jCCAZOgAwIBAgIGAW7GQ37gMAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAxOTEyMDIxMDU5MDJaGA8yMDI5MTIwMjEwNTkwMlowFzEVMBMGA1UEAwwMdGFzc3Rlc3Rfc20yMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEhNZZgdSNOhbsUPE2Lr4qZRGVXoaYFzlPnufEO0Jfsbp3T5xQpn2LM+3JlBCUBQzYIIMGK/nCyg7i0aohRc89t4EUAENOPXRhc3N0ZXN0X3NtMnJvb3SCEABDTj10YXNzdGVzdF9zbTKjgZowgZcwDAYDVR0PBAUDAwD/gDAfBgNVHSMEGDAWgBRrkGAbQCxMfbBzis7O6/Xoy1+gzjAdBgNVHQ4EFgQUYCcevefQMU5JAhHOwTldsZC00eYwRwYDVR0lBEAwPgYIKwYBBQUHAwQGCCsGAQUFBwMCBgorBgEEAYI3FAICBggrBgEFBQcDAwYIKwYBBQUHAwEGCCsGAQUFBwMCMAoGCCqBHM9VAYN1A0kAMEYCIQDaHMUodHyla5yBh9MADV1duQ+i1NBnqQBLJh6LHt3dUQIhANhye2P0aS3oSYPNuM/nRabGxSxImOAUJCsq+vsGJWhT";
//        String sealCert3 = "MIICxjCCAmygAwIBAgIGAXNbdFEGMAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAAQm7GSC7DK5zeYm/fY4gIJUrGyyezIxsVLk+SOkaIZzZrmi2QzaHoehQZ37Nn2DztFekNZWoUUsJRiwaR44mXXMgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFIu2x5K4zn6Cmgrzv500twaWZ66PMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiEAtfCQmt8WlOUoQl1s6GMwKv3+B6BAV5BOYqzNKsTd9vMCIEe0yFwGIfZudfvqGnd9WgN2grLuYwVboELaHH7GJ9pW";
//        String sealCert4 = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        List<String> sealCerts = new ArrayList<String>();
//        sealCerts.add(sealCert1);
//        sealCerts.add(sealCert2);
//        sealCerts.add(sealCert3);
//        sealCerts.add(sealCert4);
//        String startTime = "2020-7-20 12:00:00";
//        String endTime = "2029-10-01 12:00:00";
//        Date sTime = new Date();
//        Date eTime = new Date();
//        DateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
//        try {
//            sTime = format.parse(startTime);
//            eTime = format.parse(endTime);
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//
//        MakeSealResponse makeSeal = signServerApi.makeSeal("tasstest_sm2", 0, "", "SM3WITHSM2", 1, 1, "测试公章", sTime, eTime, "jpg", Base64.toBase64String(sealPic), 60, 60, sealCerts, 1, true);
//        System.out.println("生成电子印章(内部密钥)：" + String.format(printFormat, makeSeal.getCode(), makeSeal.getMsg(), "电子印章数据：" + makeSeal.getSeal()));
//        return makeSeal.getSeal();
//    }
//
//    private static String makeSealExternal() throws TAException {
//        //
//        //GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo/R/D+OzW0QcEl4fr63mgZGwxGHoUGZYfYLO1LEgo2c5wCkQ6+DhslG0ZUd1ycAqOM=
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo+dreBh4ToX1vK4RgqYmNynRKgsjIaZuP1U+KQyQsL0CRuk4/ziNASlc52wzFhLxX0=";
//        String cert = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        String startTime = "2020-7-20 12:00:00";
//        String endTime = "2029-10-01 12:00:00";
//        Date sTime = new Date();
//        Date eTime = new Date();
//        DateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
//        try {
//            sTime = format.parse(startTime);
//            eTime = format.parse(endTime);
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        byte[] sealPic = FileUtils.getBytesByFile("./test.jpg");
//        String sealCert2 = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        List<String> sealCerts = new ArrayList<String>();
//        sealCerts.add(sealCert2);
//        MakeSealResponse makeSealResponse = signServerApi.makeSealExternal(privKey, "sm1", "", 0, 1, "", cert, "SM3WITHSM2", 4, 1, "测试公章", sTime, eTime, "jpg", Base64.toBase64String(sealPic), 60, 60, sealCerts, 1, true);
//        System.out.println("生成电子印章(外部密钥)：" + String.format(printFormat, makeSealResponse.getCode(), makeSealResponse.getMsg(), "电子印章数据：" + makeSealResponse.getSeal()));
//        return makeSealResponse.getSeal();
//    }
//
//    /**
//     * @return void
//     * @Description: 验证电子印章
//     * @Author: zln[zhanglanni@tass.com.cn]
//     * @Param: []
//     * @CreatedTime: 18:31 2020/7/17
//     * @changeLog
//     **/
//    private static void verifySeal() throws TAException {
//        Date date = new Date();
//        String seal = makeSeal();
//        System.out.println("电子印章：" + seal);
//        VerifySealResponse verifySealResponse = signServerApi.verifySeal(date, seal);
//        System.out.println("验证电子印章：" + String.format(printFormat, verifySealResponse.getCode(), verifySealResponse.getMsg(), ""));
//    }
//
//    private static String makeESign() throws TAException {
//        String seal = makeSeal();
//        String propertyInfo = "aaaaa123456781234567812345678123456781234567812" +
//                "3456781234567812345678123456781234567812345678123456781234567812345" +
//                "6781234567812345678";
//        String dataHash = "Fqv91X9Sg3RX029+O16AblaOO9pq2SAln+xM61s4KSE=";
//        MakeESignResponse makeESignResponse = signServerApi.makeESign("tasstest_sm2", 0, "", "SM3WITHSM2", seal, dataHash, propertyInfo, true, true, "");
//        System.out.println("电子签章(内部密钥)：" + String.format(printFormat, makeESignResponse.getCode(), makeESignResponse.getMsg(), makeESignResponse.getEsign()));
//        return makeESignResponse.getEsign();
//    }
//
//    private static String makeESignExternal() throws TAException {
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo+dreBh4ToX1vK4RgqYmNynRKgsjIaZuP1U+KQyQsL0CRuk4/ziNASlc52wzFhLxX0=";
//        String dataHash = "Fqv91X9Sg3RX029+O16AblaOO9pq2SAln+xM61s4KSE=";
//        String propertyInfo = "aaaaa123456781234567812345678123456781234567812" +
//                "3456781234567812345678123456781234567812345678123456781234567812345" +
//                "6781234567812345678";
//        String seal = makeSealExternal();
//        String cert = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//
//        MakeESignResponse makeESignResponse = signServerApi.makeESignExternal(privKey, "sm1", "", 0, 1, "", cert, "SM3WITHSM2", seal, dataHash, propertyInfo, true, true, "");
//        System.out.println("电子签章(外部密钥)：" + String.format(printFormat, makeESignResponse.getCode(), makeESignResponse.getMsg(), makeESignResponse.getEsign()));
//        return makeESignResponse.getEsign();
//    }
//
//    private static String verifyESign() throws TAException {
//        String dataHash = "Fqv91X9Sg3RX029+O16AblaOO9pq2SAln+xM61s4KSE=";
//        String esign = makeESignExternal();
//        VerifyESignResponse verifyESignResponse = signServerApi.verifyESign(dataHash, esign, true, "");
//        System.out.println("验证电子签章：" + String.format(printFormat, verifyESignResponse.getCode(), verifyESignResponse.getMsg(), verifyESignResponse.getCert()));
//        return verifyESignResponse.getCert();
//    }
//    ///////////////////////////////////////////////////////////////////////////
//    // OFD 相关指令
//    ///////////////////////////////////////////////////////////////////////////
//
//    private static String ofdSign() throws TAException {
//        String sealPic = makeSeal();
//        String odfFile = "UEsDBBQAAAgIAG9qwVD5uwGR5QAAAKQBAAASAAAARG9jXzAvRG9jdW1l" +
//                "bnQueG1sbVBda8IwFH3frwj3fU0q4rbSRtQiCBuMMZ9HFrNaaHNLE239917bqlN8SLj" +
//                "nnnPuVzxty4LtTe1ytAmEgQBmrMZNbrME1t/L51eYyqcY/zZRinpXGusZWayLKJXA1v" +
//                "sq4rxpmoCwq4wOsM74SIQTkJ1rgWWJNlVe9fhTZWZWmzPaHlyuVTHHVgom2Cik9/YS8" +
//                "3uyU8+qqqCEp1kfGu74ocptw90vSb6Mk5cooH0G6YXstB+qXdvcr1I57vlrosePdnPX" +
//                "kK1SOimwuXLmHXUCHc9P/4/gC7SernnqDvzfrG6Iz+eWR1BLAwQUAAAIAABvasFQAAA" + "AAAAAAAAAAAAADAAAAERvY18wL1BhZ2VzL1BLAwQUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAERvY18wL1BhZ2VzL1BhZ2VfMC9QSwMEFAAACAgAb2rBUKOhSvb4AAAAjAEAA" +
//                "B4AAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWyzsa/IzVEoSy0qzszPs1Uy" +
//                "1DNQUkjNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpITE9VACrPK7YCcm2VMkpKCqz09cv" +
//                "Ly/WA/OKC1GS9/KJ0fSMDQzMlO7AO5/y8ktS8EgjHJ7EytUjB08VWyQgqHZJaUeKflJ" +
//                "WaXAIWNlFScMovzUtJLKq0VTI21DNXMDLVM1EwtlQwVVJwAxoFFFVSCM6sSgUygA5FG" +
//                "OKcn5KqEGGrBHR8JFiRS2pOSSJQwFgBAg31TCnBSnZP9i54unTv04kN7/f0hDgGBysU" +
//                "pxWnQNH7PY02+shOsUNwId6DCoBDAMqGB40+LGjtAFBLAwQUAAAICABvasFQHZrvYpY" +
//                "AAAC/AAAAEwAAAERvY18wL1B1YmxpY1Jlcy54bWyzsa/IzVEoSy0qzszPs1Uy1DNQUk" +
//                "jNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpKLVYAqs4rtgLybJUySkoKrPT1y8vL9YD84" +
//                "oLUZL38onR9IwNDMyUFp8TiVJ/8ZFsloCYlO7B2t/y8kmIEUwFE+CXmptoqPV3X/WTv" +
//                "ZCUFt8TczJxKVDFPF1slYyV9Oxt9JDP0oc6xAwBQSwMEFAAACAAAb2rBUAAAAAAAAAA" +
//                "AAAAAAAYAAABEb2NfMC9QSwMEFAAACAgAb2rBUKYC3bvtAAAAmwEAAAcAAABPRkQueG" +
//                "1sVZDLTsMwEEX3fEXkRXfxi+bZxJUgqsQKqWphiULilErEEyWG0L9nSEseG4+u7/Edz" +
//                "yTbn/rT+dZtdwaTEkE5cbQpoDybU0qOh50bkq26S6Aq4+dd5iBtuhhVSj6sbWLG+r6n" +
//                "qLtGFxTaE5Nc+MR5WSRmUBwujU4JRhA1hOHVA5SXUTyZCiaRqSh8v4+0V5RVEKylt44" +
//                "8mQdVIMJKY/WjhE3s8Oyx1bnFlllutZJccpf7LhdXbmFOOLTqb6j9Kq+bzesMRWNO3a" +
//                "ZRgnqUL7B/Z/rOfI49gFVY3zjD86vWxlLc4AgP/qiu+2C3VatfUEsBAhQAFAAACAgAb" +
//                "2rBUPm7AZHlAAAApAEAABIAAAAAAAAAAAAgAAAAAAAAAERvY18wL0RvY3VtZW50Lnht" +
//                "bFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAABUBAABEb2N" +
//                "fMC9QYWdlcy9QSwECFAAUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAA" +
//                "A/AQAARG9jXzAvUGFnZXMvUGFnZV8wL1BLAQIUABQAAAgIAG9qwVCjoUr2+AAAAIwBA" +
//                "AAeAAAAAAAAAAAAIAAAAHABAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWxQ" +
//                "SwECFAAUAAAICABvasFQHZrvYpYAAAC/AAAAEwAAAAAAAAAAACAAAACkAgAARG9jXzA" +
//                "vUHVibGljUmVzLnhtbFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAGAAAAAAAAAA" +
//                "AAAAAAAGsDAABEb2NfMC9QSwECFAAUAAAICABvasFQpgLdu+0AAACbAQAABwAAAAAAA" +
//                "AAAACAAAACPAwAAT0ZELnhtbFBLBQYAAAAABwAHALEBAAChBAAAAAA=";
//        OfdSignResponse ofdSignResponse = signServerApi.ofdSign("tasstest_sm2", 0, "", "SM3WITHSM2", true, false, false, "", 1, 0.0, 0.0, 40.0, 40.0, odfFile, sealPic);
//        System.out.println("OFD 文件签章(内部密钥)：" + String.format(printFormat, ofdSignResponse.getCode(), ofdSignResponse.getMsg(), ofdSignResponse.getSignOfd()));
//        return ofdSignResponse.getSignOfd();
//    }
//
//    private static String ofdSignExternal() throws TAException {
//
//        String cert = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        String sealPic = makeSealExternal();
//
//        String privKey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo+dreBh4ToX1vK4RgqYmNynRKgsjIaZuP1U+KQyQsL0CRuk4/ziNASlc52wzFhLxX0=";
//        String odfFile = "UEsDBBQAAAgIAG9qwVD5uwGR5QAAAKQBAAASAAAARG9jXzAvRG9jdW1l" +
//                "bnQueG1sbVBda8IwFH3frwj3fU0q4rbSRtQiCBuMMZ9HFrNaaHNLE239917bqlN8SLj" +
//                "nnnPuVzxty4LtTe1ytAmEgQBmrMZNbrME1t/L51eYyqcY/zZRinpXGusZWayLKJXA1v" +
//                "sq4rxpmoCwq4wOsM74SIQTkJ1rgWWJNlVe9fhTZWZWmzPaHlyuVTHHVgom2Cik9/YS8" +
//                "3uyU8+qqqCEp1kfGu74ocptw90vSb6Mk5cooH0G6YXstB+qXdvcr1I57vlrosePdnPX" +
//                "kK1SOimwuXLmHXUCHc9P/4/gC7SernnqDvzfrG6Iz+eWR1BLAwQUAAAIAABvasFQAAA" + "AAAAAAAAAAAAADAAAAERvY18wL1BhZ2VzL1BLAwQUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAERvY18wL1BhZ2VzL1BhZ2VfMC9QSwMEFAAACAgAb2rBUKOhSvb4AAAAjAEAA" +
//                "B4AAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWyzsa/IzVEoSy0qzszPs1Uy" +
//                "1DNQUkjNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpITE9VACrPK7YCcm2VMkpKCqz09cv" +
//                "Ly/WA/OKC1GS9/KJ0fSMDQzMlO7AO5/y8ktS8EgjHJ7EytUjB08VWyQgqHZJaUeKflJ" +
//                "WaXAIWNlFScMovzUtJLKq0VTI21DNXMDLVM1EwtlQwVVJwAxoFFFVSCM6sSgUygA5FG" +
//                "OKcn5KqEGGrBHR8JFiRS2pOSSJQwFgBAg31TCnBSnZP9i54unTv04kN7/f0hDgGBysU" +
//                "pxWnQNH7PY02+shOsUNwId6DCoBDAMqGB40+LGjtAFBLAwQUAAAICABvasFQHZrvYpY" +
//                "AAAC/AAAAEwAAAERvY18wL1B1YmxpY1Jlcy54bWyzsa/IzVEoSy0qzszPs1Uy1DNQUk" +
//                "jNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpKLVYAqs4rtgLybJUySkoKrPT1y8vL9YD84" +
//                "oLUZL38onR9IwNDMyUFp8TiVJ/8ZFsloCYlO7B2t/y8kmIEUwFE+CXmptoqPV3X/WTv" +
//                "ZCUFt8TczJxKVDFPF1slYyV9Oxt9JDP0oc6xAwBQSwMEFAAACAAAb2rBUAAAAAAAAAA" +
//                "AAAAAAAYAAABEb2NfMC9QSwMEFAAACAgAb2rBUKYC3bvtAAAAmwEAAAcAAABPRkQueG" +
//                "1sVZDLTsMwEEX3fEXkRXfxi+bZxJUgqsQKqWphiULilErEEyWG0L9nSEseG4+u7/Edz" +
//                "yTbn/rT+dZtdwaTEkE5cbQpoDybU0qOh50bkq26S6Aq4+dd5iBtuhhVSj6sbWLG+r6n" +
//                "qLtGFxTaE5Nc+MR5WSRmUBwujU4JRhA1hOHVA5SXUTyZCiaRqSh8v4+0V5RVEKylt44" +
//                "8mQdVIMJKY/WjhE3s8Oyx1bnFlllutZJccpf7LhdXbmFOOLTqb6j9Kq+bzesMRWNO3a" +
//                "ZRgnqUL7B/Z/rOfI49gFVY3zjD86vWxlLc4AgP/qiu+2C3VatfUEsBAhQAFAAACAgAb" +
//                "2rBUPm7AZHlAAAApAEAABIAAAAAAAAAAAAgAAAAAAAAAERvY18wL0RvY3VtZW50Lnht" +
//                "bFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAABUBAABEb2N" +
//                "fMC9QYWdlcy9QSwECFAAUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAA" +
//                "A/AQAARG9jXzAvUGFnZXMvUGFnZV8wL1BLAQIUABQAAAgIAG9qwVCjoUr2+AAAAIwBA" +
//                "AAeAAAAAAAAAAAAIAAAAHABAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWxQ" +
//                "SwECFAAUAAAICABvasFQHZrvYpYAAAC/AAAAEwAAAAAAAAAAACAAAACkAgAARG9jXzA" +
//                "vUHVibGljUmVzLnhtbFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAGAAAAAAAAAA" +
//                "AAAAAAAGsDAABEb2NfMC9QSwECFAAUAAAICABvasFQpgLdu+0AAACbAQAABwAAAAAAA" +
//                "AAAACAAAACPAwAAT0ZELnhtbFBLBQYAAAAABwAHALEBAAChBAAAAAA=";
//        OfdSignResponse ofdSignResponse = signServerApi.ofdSignExternal(privKey, "sm1", "", 0, 1, "", cert, "SM3WITHSM2", true, false, false, "", 1, 0.0, 0.0, 40.0, 40.0, odfFile, sealPic);
//        System.out.println("OFD 文件签章(外部密钥)：" + String.format(printFormat, ofdSignResponse.getCode(), ofdSignResponse.getMsg(), ofdSignResponse.getSignOfd()));
//        return ofdSignResponse.getSignOfd();
//    }
//
//    private static String ofdSignCrevice() throws TAException {
//        String sealPic = makeSeal();
//        String odf = "UEsDBBQAAAgIAG9qwVD5uwGR5QAAAKQBAAASAAAARG9jXzAvRG9jdW1l" +
//                "bnQueG1sbVBda8IwFH3frwj3fU0q4rbSRtQiCBuMMZ9HFrNaaHNLE239917bqlN8SLj" +
//                "nnnPuVzxty4LtTe1ytAmEgQBmrMZNbrME1t/L51eYyqcY/zZRinpXGusZWayLKJXA1v" +
//                "sq4rxpmoCwq4wOsM74SIQTkJ1rgWWJNlVe9fhTZWZWmzPaHlyuVTHHVgom2Cik9/YS8" +
//                "3uyU8+qqqCEp1kfGu74ocptw90vSb6Mk5cooH0G6YXstB+qXdvcr1I57vlrosePdnPX" +
//                "kK1SOimwuXLmHXUCHc9P/4/gC7SernnqDvzfrG6Iz+eWR1BLAwQUAAAIAABvasFQAAA" +
//                "AAAAAAAAAAAAADAAAAERvY18wL1BhZ2VzL1BLAwQUAAAIAABvasFQAAAAAAAAAAAAAA" +
//                "AAEwAAAERvY18wL1BhZ2VzL1BhZ2VfMC9QSwMEFAAACAgAb2rBUKOhSvb4AAAAjAEAA" +
//                "B4AAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWyzsa/IzVEoSy0qzszPs1Uy" +
//                "1DNQUkjNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpITE9VACrPK7YCcm2VMkpKCqz09cv" +
//                "Ly/WA/OKC1GS9/KJ0fSMDQzMlO7AO5/y8ktS8EgjHJ7EytUjB08VWyQgqHZJaUeKflJ" +
//                "WaXAIWNlFScMovzUtJLKq0VTI21DNXMDLVM1EwtlQwVVJwAxoFFFVSCM6sSgUygA5FG" +
//                "OKcn5KqEGGrBHR8JFiRS2pOSSJQwFgBAg31TCnBSnZP9i54unTv04kN7/f0hDgGBysU" +
//                "pxWnQNH7PY02+shOsUNwId6DCoBDAMqGB40+LGjtAFBLAwQUAAAICABvasFQHZrvYpY" +
//                "AAAC/AAAAEwAAAERvY18wL1B1YmxpY1Jlcy54bWyzsa/IzVEoSy0qzszPs1Uy1DNQUk" +
//                "jNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpKLVYAqs4rtgLybJUySkoKrPT1y8vL9YD84" +
//                "oLUZL38onR9IwNDMyUFp8TiVJ/8ZFsloCYlO7B2t/y8kmIEUwFE+CXmptoqPV3X/WTv" +
//                "ZCUFt8TczJxKVDFPF1slYyV9Oxt9JDP0oc6xAwBQSwMEFAAACAAAb2rBUAAAAAAAAAA" +
//                "AAAAAAAYAAABEb2NfMC9QSwMEFAAACAgAb2rBUKYC3bvtAAAAmwEAAAcAAABPRkQueG" +
//                "1sVZDLTsMwEEX3fEXkRXfxi+bZxJUgqsQKqWphiULilErEEyWG0L9nSEseG4+u7/Edz" +
//                "yTbn/rT+dZtdwaTEkE5cbQpoDybU0qOh50bkq26S6Aq4+dd5iBtuhhVSj6sbWLG+r6n" +
//                "qLtGFxTaE5Nc+MR5WSRmUBwujU4JRhA1hOHVA5SXUTyZCiaRqSh8v4+0V5RVEKylt44" + "8mQdVIMJKY/WjhE3s8Oyx1bnFlllutZJccpf7LhdXbmFOOLTqb6j9Kq+bzesMRWNO3a" +
//                "ZRgnqUL7B/Z/rOfI49gFVY3zjD86vWxlLc4AgP/qiu+2C3VatfUEsBAhQAFAAACAgAb" +
//                "2rBUPm7AZHlAAAApAEAABIAAAAAAAAAAAAgAAAAAAAAAERvY18wL0RvY3VtZW50Lnht" +
//                "bFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAABUBAABEb2N" +
//                "fMC9QYWdlcy9QSwECFAAUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAA" +
//                "A/AQAARG9jXzAvUGFnZXMvUGFnZV8wL1BLAQIUABQAAAgIAG9qwVCjoUr2+AAAAIwBA" +
//                "AAeAAAAAAAAAAAAIAAAAHABAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWxQ" +
//                "SwECFAAUAAAICABvasFQHZrvYpYAAAC/AAAAEwAAAAAAAAAAACAAAACkAgAARG9jXzA" +
//                "vUHVibGljUmVzLnhtbFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAGAAAAAAAAAA" +
//                "AAAAAAAGsDAABEb2NfMC9QSwECFAAUAAAICABvasFQpgLdu+0AAACbAQAABwAAAAAAA" +
//                "AAAACAAAACPAwAAT0ZELnhtbFBLBQYAAAAABwAHALEBAAChBAAAAAA=";
//        OfdSignResponse ofdSignResponse = signServerApi.ofdSignCrevice("tasstest_sm2", 0, "", "SM3WITHSM2", true, false, true, "right", 1, 0.0, 0.0, 10.0, 10.0, odf, sealPic);
//        System.out.println("OFD 文件骑缝章签章(内部密钥)：" + String.format(printFormat, ofdSignResponse.getCode(), ofdSignResponse.getMsg(), ofdSignResponse.getSignOfd()));
//        return ofdSignResponse.getSignOfd();
//    }
//
//    private static String ofdSignExternalCrevice() throws TAException {
//        String sealPic = makeSealExternal();
//        String privkey = "GA0Rnxi+J1jJ2ni8FwXS13pm8YNDHJD6NhHjfYLJIo+dreBh4ToX1vK4RgqYmNynRKgsjIaZuP1U+KQyQsL0CRuk4/ziNASlc52wzFhLxX0=";
//        String cert = "MIICxjCCAmygAwIBAgIGAXNbdFD8MAoGCCqBHM9VAYN1MG4xHDAaBgNVBAMME1RBU1PmtYvor5XmoLnor4HkuaYxCzAJBgNVBAYMAmNuMRIwEAYDVQQIDAlHdWFuZ3pob3UxFjAUBgNVBAoMDUJlaSBKaW5nIEpOVEExFTATBgNVBAsMDOeglOWPkeS6jOmDqDAiGA8yMDIwMDcxNzA2MjY1NloYDzIwMzAwNzE3MDYyNjU2WjBTMQwwCgYDVQQDDAN6bG4xCzAJBgNVBAYMAkNOMQswCQYDVQQIDAJiajELMAkGA1UEBwwCYmoxDTALBgNVBAoMBHRhc3MxDTALBgNVBAsMBHRhc3MwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATKvoo7gduim6iRilMOqq4APeDFtWq2QxZM5px5ZGNbyv8gIVuhFxxkvkm3C2gmMHyiKgWgZic2DKQ6oVHNcHvhgUkAQ049VEFTU+a1i+ivleagueivgeS5pixDPWNuLFNUPUd1YW5nemhvdSxPPUJlaSBKaW5nIEpOVEEsT1U956CU5Y+R5LqM6YOogiYAQ049emxuLEM9Q04sU1Q9YmosTD1iaixPPXRhc3MsT1U9dGFzc6OBmTCBljALBgNVHQ8EBAMCAAAwHwYDVR0jBBgwFoAUUQaXjCDrcQFQwEmjHGA6Qmn9X0AwHQYDVR0OBBYEFNYHSMnHY0YCp0RL+Ys4CDtN+6GMMEcGA1UdJQRAMD4GCCsGAQUFBwMEBggrBgEFBQcDAgYKKwYBBAGCNxQCAgYIKwYBBQUHAwMGCCsGAQUFBwMBBggrBgEFBQcDAjAKBggqgRzPVQGDdQNIADBFAiAc0Dp+w/CVVbBNWm9ojHZD+OAPchTsbzrfL8Mydc9kVQIhAMZ8/oE26ptGpHoT8rofN5SoB1/+FDFmxHBpfCA8NSbZ";
//        String odf = "UEsDBBQAAAgIAG9qwVD5uwGR5QAAAKQBAAASAAAARG9jXzAvRG9jdW1l" +
//                "bnQueG1sbVBda8IwFH3frwj3fU0q4rbSRtQiCBuMMZ9HFrNaaHNLE239917bqlN8SLj" +
//                "nnnPuVzxty4LtTe1ytAmEgQBmrMZNbrME1t/L51eYyqcY/zZRinpXGusZWayLKJXA1v" +
//                "sq4rxpmoCwq4wOsM74SIQTkJ1rgWWJNlVe9fhTZWZWmzPaHlyuVTHHVgom2Cik9/YS8" +
//                "3uyU8+qqqCEp1kfGu74ocptw90vSb6Mk5cooH0G6YXstB+qXdvcr1I57vlrosePdnPX" +
//                "kK1SOimwuXLmHXUCHc9P/4/gC7SernnqDvzfrG6Iz+eWR1BLAwQUAAAIAABvasFQAAA" +
//                "AAAAAAAAAAAAADAAAAERvY18wL1BhZ2VzL1BLAwQUAAAIAABvasFQAAAAAAAAAAAAAA" +
//                "AAEwAAAERvY18wL1BhZ2VzL1BhZ2VfMC9QSwMEFAAACAgAb2rBUKOhSvb4AAAAjAEAA" +
//                "B4AAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWyzsa/IzVEoSy0qzszPs1Uy" +
//                "1DNQUkjNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpITE9VACrPK7YCcm2VMkpKCqz09cv" +
//                "Ly/WA/OKC1GS9/KJ0fSMDQzMlO7AO5/y8ktS8EgjHJ7EytUjB08VWyQgqHZJaUeKflJ" +
//                "WaXAIWNlFScMovzUtJLKq0VTI21DNXMDLVM1EwtlQwVVJwAxoFFFVSCM6sSgUygA5FG" +
//                "OKcn5KqEGGrBHR8JFiRS2pOSSJQwFgBAg31TCnBSnZP9i54unTv04kN7/f0hDgGBysU" +
//                "pxWnQNH7PY02+shOsUNwId6DCoBDAMqGB40+LGjtAFBLAwQUAAAICABvasFQHZrvYpY" +
//                "AAAC/AAAAEwAAAERvY18wL1B1YmxpY1Jlcy54bWyzsa/IzVEoSy0qzszPs1Uy1DNQUk" +
//                "jNS85PycxLt1UKDXHTtVCyt+OyyU9LsQpKLVYAqs4rtgLybJUySkoKrPT1y8vL9YD84" +
//                "oLUZL38onR9IwNDMyUFp8TiVJ/8ZFsloCYlO7B2t/y8kmIEUwFE+CXmptoqPV3X/WTv" +
//                "ZCUFt8TczJxKVDFPF1slYyV9Oxt9JDP0oc6xAwBQSwMEFAAACAAAb2rBUAAAAAAAAAA" +
//                "AAAAAAAYAAABEb2NfMC9QSwMEFAAACAgAb2rBUKYC3bvtAAAAmwEAAAcAAABPRkQueG" +
//                "1sVZDLTsMwEEX3fEXkRXfxi+bZxJUgqsQKqWphiULilErEEyWG0L9nSEseG4+u7/Edz" +
//                "yTbn/rT+dZtdwaTEkE5cbQpoDybU0qOh50bkq26S6Aq4+dd5iBtuhhVSj6sbWLG+r6n" +
//                "qLtGFxTaE5Nc+MR5WSRmUBwujU4JRhA1hOHVA5SXUTyZCiaRqSh8v4+0V5RVEKylt44" + "8mQdVIMJKY/WjhE3s8Oyx1bnFlllutZJccpf7LhdXbmFOOLTqb6j9Kq+bzesMRWNO3a" +
//                "ZRgnqUL7B/Z/rOfI49gFVY3zjD86vWxlLc4AgP/qiu+2C3VatfUEsBAhQAFAAACAgAb" +
//                "2rBUPm7AZHlAAAApAEAABIAAAAAAAAAAAAgAAAAAAAAAERvY18wL0RvY3VtZW50Lnht" +
//                "bFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAABUBAABEb2N" +
//                "fMC9QYWdlcy9QSwECFAAUAAAIAABvasFQAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAA" +
//                "A/AQAARG9jXzAvUGFnZXMvUGFnZV8wL1BLAQIUABQAAAgIAG9qwVCjoUr2+AAAAIwBA" +
//                "AAeAAAAAAAAAAAAIAAAAHABAABEb2NfMC9QYWdlcy9QYWdlXzAvQ29udGVudC54bWxQ" +
//                "SwECFAAUAAAICABvasFQHZrvYpYAAAC/AAAAEwAAAAAAAAAAACAAAACkAgAARG9jXzA" +
//                "vUHVibGljUmVzLnhtbFBLAQIUABQAAAgAAG9qwVAAAAAAAAAAAAAAAAAGAAAAAAAAAA" +
//                "AAAAAAAGsDAABEb2NfMC9QSwECFAAUAAAICABvasFQpgLdu+0AAACbAQAABwAAAAAAA" +
//                "AAAACAAAACPAwAAT0ZELnhtbFBLBQYAAAAABwAHALEBAAChBAAAAAA=";
//        OfdSignResponse ofdSignResponse = signServerApi.ofdSignExternalCrevice(privkey, "sm1", "", 0, 1, "", cert, TACryptConst.TA_S_ALG_SM3WITHSM2, true, false, true, "right", 1, 0.0, 0.0, 40.0, 40.0, odf, sealPic);
//        System.out.println("OFD 文件骑缝章签章(外部密钥)：" + String.format(printFormat, ofdSignResponse.getCode(), ofdSignResponse.getMsg(), ofdSignResponse.getSignOfd()));
//        return ofdSignResponse.getSignOfd();
//    }
//
//
//    private static void verifyOfdSign() throws TAException {
//        String odf = ofdSignCrevice();
//        String cert = verifyESign();
//        VerifyOfdSignResponse verifyOfdSignResponse = signServerApi.verifyOfdSign(odf, "");
//        System.out.println("验证OFD文件签章：" + String.format(printFormat, verifyOfdSignResponse.getCode(), verifyOfdSignResponse.getMsg(), ""));
//    }
//
//    ///////////////////////////////////////////////////////////////////////////
//    // 时间戳 相关指令
//    ///////////////////////////////////////////////////////////////////////////
//
//    /**
//     * 生成时间戳
//     *
//     * @throws TAException
//     */
//    private static void genTimeStamp() throws TAException {
//        System.out.println("开始生成时间戳");
//        //data
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ=";
//        Integer dataType = 0;
//        String algorithm = "SM3";
//        String policy = "";
//        String nonce = "";
//        boolean isIncludeCert = true;
//        boolean isHash = false;
//        List<TSPExtension> extensions = new ArrayList<TSPExtension>();
//        TSPAccuracy accuracy = new TSPAccuracy();
//        GenTimeStampResponse genTimeStampResponse = signServerApi.genTimeStamp(data, dataType, algorithm, policy, nonce, isIncludeCert, extensions, accuracy);
//        System.out.println("时间戳生成完毕：" + String.format(printFormat, genTimeStampResponse.getCode(), genTimeStampResponse.getMsg(), genTimeStampResponse.getTimeStamp()));
//    }
//
//    /**
//     * 验证时间戳
//     */
//    private static void verifyTimeStamp() throws TAException {
//        System.out.println("开始验证时间戳");
//        //data
//        String data = "MTIzNDU2NzgxMjM0NTY3ODEyMzQ=";
//        Integer dataType = 0;
//        String timeStamp = "MIIEnQYJKoZIhvcNAQcCoIIEjjCCBIoCAQMxDjAMBggqgRzPVQGDEQUAMIHpBgsqhkiG9w0BCRABBKCB2QSB1jCB0wIBA" +
//                "QYDKQEBMDAwDAYIKoEcz1UBgxEFAAQg6ZZPrVTd9f7J2QZ1iqRhx4RDI3pTbLWZTCeWZy6LyGgCB0fEiuPRowMYEzIwMjAwODI0MDcz" +
//                "MTU0LjMwOVqgeaR3MHUxEjAQBgNVBAMMCXNtMnRpbWVDTjESMBAGA1UECwwJc20ydGltZU9VMREwDwYDVQQKDAhzbTJ0aW1lTzERMA8" +
//                "GA1UEBwwIc20ydGltZUwxEjAQBgNVBAgMCXNtMnRpbWVTVDERMA8GA1UEBhMIc20ydGltZUOgggJUMIICUDCCAfWgAwIBAgIGAXP7u" +
//                "BvYMAoGCCqBHM9VAYN1MBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAyMDA4MTcwOTIwMTNaGA8yMDMwMDgxNzA5MjAxM" +
//                "1owdTESMBAGA1UEAwwJc20ydGltZUNOMREwDwYDVQQGDAhzbTJ0aW1lQzESMBAGA1UECAwJc20ydGltZVNUMREwDwYDVQQHDAhzbTJ0aW" +
//                "1lTDERMA8GA1UECgwIc20ydGltZU8xEjAQBgNVBAsMCXNtMnRpbWVPVTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABNBhPmsG0e0cr/" +
//                "Bb7GEQDeEckXntesy5h0qHudAv1FTL5pCAjL85gSXKFOYLTRgF1Wm0R9ur1Wz7TDF9Mlo1qEmBFABDTj10YXNzdGVzdF9zbTJyb290gkg" +
//                "AQ049c20ydGltZUNOLEM9c20ydGltZUMsU1Q9c20ydGltZVNULEw9c20ydGltZUwsTz1zbTJ0aW1lTyxPVT1zbTJ0aW1lT1WjZzBlMAsGA" +
//                "1UdDwQEAwIAwDAfBgNVHSMEGDAWgBRrkGAbQCxMfbBzis7O6/Xoy1+gzjAdBgNVHQ4EFgQUJQHK0Jge6cSMYB2B1spUS1GlkFQwFgYDVR0l" +
//                "AQH/BAwwCgYIKwYBBQUHAwgwCgYIKoEcz1UBg3UDSQAwRgIhAIMdl8QDubbkG6df1lEW74xstZLHaJsWQ1SQ3HsxLrfHAiEAuFAebPi42HdQ" +
//                "nj3H9cw7kRKVIngOLOtgUb9LwNjtHJMxggEvMIIBKwIBATAlMBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QCBgFz+7gb2DAMBggqgRzP" +
//                "VQGDEQUAoIGYMBoGCSqGSIb3DQEJAzENBgsqhkiG9w0BCRABBDAcBgkqhkiG9w0BCQUxDxcNMjAwODI0MDczMTU0WjArBgsqhkiG9w0BCR" +
//                "ACDDEcMBowGDAWBBQ1DQMpzmg6nv0gjT3muHlvxoQxozAvBgkqhkiG9w0BCQQxIgQgyx4yZF0EWaZivcMjJs2iTdcZ5YfKkS0Ih+WY/YMJV" +
//                "OkwDQYJKoEcz1UBgi0BBQAERzBFAiBHjNJkaBkXvp9PANx4Cdm9oYgxqOfTOk0qJnkFKaCDtAIhAKuhVQpAxe0XNoIMX+lrdNK/CnFS3LPx" +
//                "E1n5F5tHcUG0";
//        VerifyTimeStampResponse verifyTimeStampResponse = signServerApi.verifyTimeStamp(data, dataType, timeStamp);
//        System.out.println("时间戳验证完毕：" + String.format(printFormat, verifyTimeStampResponse.getCode(), verifyTimeStampResponse.getMsg(), verifyTimeStampResponse.getCert()));
//
//    }
//
//    /**
//     * 获取时间戳信息
//     */
//    private static void getTimeStampInfo() throws TAException {
//        System.out.println("开始获取时间戳信息");
//        Integer infoType = 0;
//        String timeStamp = "MIIEnQYJKoZIhvcNAQcCoIIEjjCCBIoCAQMxDjAMBggqgRzPVQGDEQUAMIHpBgsqhkiG9w0BCRABBKCB2QSB1jCB0wIBAQYDKQEB" +
//                "MDAwDAYIKoEcz1UBgxEFAAQg6ZZPrVTd9f7J2QZ1iqRhx4RDI3pTbLWZTCeWZy6LyGgCB0fEiuPRowMYEzIwMjAwODI0MDczMTU0LjMwOVqg" +
//                "eaR3MHUxEjAQBgNVBAMMCXNtMnRpbWVDTjESMBAGA1UECwwJc20ydGltZU9VMREwDwYDVQQKDAhzbTJ0aW1lTzERMA8GA1UEBwwIc20ydGlt" +
//                "ZUwxEjAQBgNVBAgMCXNtMnRpbWVTVDERMA8GA1UEBhMIc20ydGltZUOgggJUMIICUDCCAfWgAwIBAgIGAXP7uBvYMAoGCCqBHM9VAYN1MBs" +
//                "xGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QwIhgPMjAyMDA4MTcwOTIwMTNaGA8yMDMwMDgxNzA5MjAxM1owdTESMBAGA1UEAwwJc20ydGlt" +
//                "ZUNOMREwDwYDVQQGDAhzbTJ0aW1lQzESMBAGA1UECAwJc20ydGltZVNUMREwDwYDVQQHDAhzbTJ0aW1lTDERMA8GA1UECgwIc20ydGltZU8x" +
//                "EjAQBgNVBAsMCXNtMnRpbWVPVTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABNBhPmsG0e0cr/Bb7GEQDeEckXntesy5h0qHudAv1FTL5pCAj" +
//                "L85gSXKFOYLTRgF1Wm0R9ur1Wz7TDF9Mlo1qEmBFABDTj10YXNzdGVzdF9zbTJyb290gkgAQ049c20ydGltZUNOLEM9c20ydGltZUMsU1Q9c" +
//                "20ydGltZVNULEw9c20ydGltZUwsTz1zbTJ0aW1lTyxPVT1zbTJ0aW1lT1WjZzBlMAsGA1UdDwQEAwIAwDAfBgNVHSMEGDAWgBRrkGAbQCxMfb" +
//                "Bzis7O6/Xoy1+gzjAdBgNVHQ4EFgQUJQHK0Jge6cSMYB2B1spUS1GlkFQwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwCgYIKoEcz1UBg3UDSQAwR" +
//                "gIhAIMdl8QDubbkG6df1lEW74xstZLHaJsWQ1SQ3HsxLrfHAiEAuFAebPi42HdQnj3H9cw7kRKVIngOLOtgUb9LwNjtHJMxggEvMIIBKwIBATA" +
//                "lMBsxGTAXBgNVBAMMEHRhc3N0ZXN0X3NtMnJvb3QCBgFz+7gb2DAMBggqgRzPVQGDEQUAoIGYMBoGCSqGSIb3DQEJAzENBgsqhkiG9w0BCRAB" +
//                "BDAcBgkqhkiG9w0BCQUxDxcNMjAwODI0MDczMTU0WjArBgsqhkiG9w0BCRACDDEcMBowGDAWBBQ1DQMpzmg6nv0gjT3muHlvxoQxozAvBgkqhki" +
//                "G9w0BCQQxIgQgyx4yZF0EWaZivcMjJs2iTdcZ5YfKkS0Ih+WY/YMJVOkwDQYJKoEcz1UBgi0BBQAERzBFAiBHjNJkaBkXvp9PANx4Cdm9oYgxqO" +
//                "fTOk0qJnkFKaCDtAIhAKuhVQpAxe0XNoIMX+lrdNK/CnFS3LPxE1n5F5tHcUG0";
//        GetTimeStampInfoResponse getTimeStampInfoResponse = signServerApi.getTimeStampInfo(infoType, timeStamp);
//        System.out.println("获取时间戳信息完毕：" + String.format(printFormat, getTimeStampInfoResponse.getCode(),
//                getTimeStampInfoResponse.getMsg(), "证书签发时间：" + getTimeStampInfoResponse.getTime() + "," +
//                        "原数据哈希值：" + getTimeStampInfoResponse.getOriginal() + "," + "证书：" + getTimeStampInfoResponse.getCert() + "," +
//                        "根证书：" + getTimeStampInfoResponse.getCertChain() + "," + "时间精度：" + getTimeStampInfoResponse.getAccuracy() + "," +
//                        "签发者国家：" + getTimeStampInfoResponse.getCountry() + "," + "签发者组织：" + getTimeStampInfoResponse.getOrganization() + "," +
//                        "签发者城市:" + getTimeStampInfoResponse.getCity() + "," + "签发者用的邮箱：" + getTimeStampInfoResponse.getEmail()));
//
//    }
//
//    public static byte[] readFile(String filePath) throws IOException {
//        RandomAccessFile raf = null;
//        byte[] data;
//        try {
//            raf = new RandomAccessFile(filePath, "r");
//            data = new byte[(int) raf.length()];
//            raf.read(data);
//            return data;
//        } finally {
//            if (raf != null) {
//                raf.close();
//            }
//        }
//    }
//}
